case SECONDS: _dateTimeTruncate = (dateTime) -> _outputDateTimeFormatter.print( dateTime.withSecondOfMinute((dateTime.getSecondOfMinute() / sz) * sz).secondOfMinute().roundFloorCopy()); break; case MINUTES:
private ReadableInstant toTimeStamp(Object inputTimestamp) { return dateTimeFormatter .parseDateTime(inputTimestamp.toString()) .secondOfMinute() .roundCeilingCopy(); } }
/** * * @param date * must have Date portion equal to Epoch * @param calendar */ public Time(final java.util.Date date, final DateTimeZone dateTimeZone) { final DateTime DateTime = new DateTime(date.getTime(), dateTimeZone); this.time = DateTime.secondOfMinute().setCopy(0); }
/** * * @param date * must have Date portion equal to Epoch * @param calendar */ public Time(final java.util.Date date, final DateTimeZone dateTimeZone) { final DateTime DateTime = new DateTime(date.getTime(), dateTimeZone); this.time = DateTime.secondOfMinute().setCopy(0); }
@Override public DateTime truncate(DateTime time) { return time.secondOfMinute().roundFloorCopy(); } },
DateTime dt = new DateTime(); dt = dt.minusMinutes(dt.minuteOfHour()).minusSecond(dt.secondOfMinute());
/** * Returns date minus 6 hours to indicate the high latency pipeline timestamp */ public static DateTime currentHighLatencyTime(DateTimeZone zone) { return new DateTime(zone).minusHours(DELAY_HOURS).minuteOfHour() .withMinimumValue().secondOfMinute().withMinimumValue().millisOfSecond() .withMinimumValue(); }
/** * Returns date minus 6 hours to indicate the high latency pipeline timestamp */ public static DateTime currentHighLatencyTime(DateTimeZone zone) { return new DateTime(zone).minusHours(DELAY_HOURS).minuteOfHour() .withMinimumValue().secondOfMinute().withMinimumValue().millisOfSecond() .withMinimumValue(); }
@Deprecated public void setStartTime(DateTime startTime) { ZonedDateTime time = ZonedDateTime.of(startTime.year().get(), startTime.monthOfYear().get(), startTime.dayOfMonth().get(), startTime.hourOfDay().get(), startTime.minuteOfHour().get(), startTime.secondOfMinute().get(), startTime.millisOfSecond().get() * 1000, ZoneId.systemDefault()); this.startTime = time; }
private static String errorCode() { DateTime now = DateTime.now(); return format("SER-%04d-%02d%02d%02d-%02d%02d-%04d ", get(now.year()), get(now.monthOfYear()), get(now.dayOfMonth()), get(now.hourOfDay()), get(now.minuteOfHour()), get(now.secondOfMinute()), get(now.millisOfSecond())); }
@Deprecated public TestStep(final DateTime startTime, final String description) { this(); ZonedDateTime time = ZonedDateTime.of(startTime.year().get(), startTime.monthOfYear().get(), startTime.dayOfMonth().get(), startTime.hourOfDay().get(), startTime.minuteOfHour().get(), startTime.secondOfMinute().get(), startTime.millisOfSecond().get() * 1000, ZoneId.systemDefault()); this.startTime = time; this.description = description; this.level = 0; }
private static String errorCode() { DateTime now = DateTime.now(); return format("SER-%04d-%02d%02d%02d-%02d%02d-%04d ", get(now.year()), get(now.monthOfYear()), get(now.dayOfMonth()), get(now.hourOfDay()), get(now.minuteOfHour()), get(now.secondOfMinute()), get(now.millisOfSecond())); }
private static String errorCode() { DateTime now = DateTime.now(); return format("SER-%04d-%02d%02d%02d-%02d%02d-%04d ", get(now.year()), get(now.monthOfYear()), get(now.dayOfMonth()), get(now.hourOfDay()), get(now.minuteOfHour()), get(now.secondOfMinute()), get(now.millisOfSecond())); }
private static String errorCode() { DateTime now = DateTime.now(); return format("SER-%04d-%02d%02d%02d-%02d%02d-%04d ", get(now.year()), get(now.monthOfYear()), get(now.dayOfMonth()), get(now.hourOfDay()), get(now.minuteOfHour()), get(now.secondOfMinute()), get(now.millisOfSecond())); }
public static Time getTimeOfDay() { org.joda.time.DateTime dt = org.joda.time.DateTime.now(); int [] values = { dt.hourOfDay().get(), dt.minuteOfHour().get(), dt.secondOfMinute().get(), dt.millisOfSecond().get() }; return new Time(new Partial(fields, values), dt.getZone()); }
public DateTime maxDateTime(DateTime dateTime) { switch (this) { case YEAR: return dateTime.dayOfYear().withMaximumValue() .secondOfDay().withMaximumValue(); case QUARTER: // TODO: case MONTH: return dateTime.dayOfMonth().withMaximumValue() .secondOfDay().withMaximumValue(); case DAY: return dateTime.secondOfDay().withMaximumValue(); case HOUR: return dateTime.minuteOfHour().withMaximumValue() .secondOfMinute().withMaximumValue(); case MINUTE: case SECOND: return dateTime.secondOfMinute().withMaximumValue(); } return dateTime; }
public static DateTime fromJodaDateTime(org.joda.time.DateTime dt) { int [] values = { dt.year().get(), dt.monthOfYear().get(), dt.dayOfMonth().get(), dt.hourOfDay().get(), dt.minuteOfHour().get(), dt.secondOfMinute().get(), dt.millisOfSecond().get() }; return new DateTime(new Partial(fields, values), dt.getZone()); }
public static DateTime dateTimeFloor(DateTime dt, Period p) { if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); } return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
public static DateTime getTimeSlice(DateTime dt, Duration duration) { Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); } return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
protected static DateTime getTimeSlice(DateTime dt, Duration duration) { Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); } return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }