@Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj instanceof PlainTimestamp) { PlainTimestamp that = (PlainTimestamp) obj; return (this.date.equals(that.date) && this.time.equals(that.time)); } else { return false; } }
private static String getFixedCode(PlainTime time) { int minuteOfDay = time.get(PlainTime.MINUTE_OF_DAY).intValue(); if ((minuteOfDay == 0) || (minuteOfDay == 1440)) { return "midnight"; } else if (minuteOfDay < 720) { return "am"; } else if (minuteOfDay == 720) { return "noon"; } else { return "pm"; } }
(context.getHour() == 24) ? PlainTime.midnightAtStartOfDay() : context); PlainTime last = this.codeMap.lastKey(); if (compare.isSimultaneous(key)) { return key; } else if (compare.isBefore(key)) { break; } else {
@Override public LocalTime from(PlainTime time) { if (time.getHour() == 24) { return LocalTime.MIDNIGHT; } return LocalTime.of(time.getHour(), time.getMinute(), time.getSecond(), time.getNanosecond()); }
/** * <p>Determines the end of the day period which covers given clock time. </p> * * @param context the clock time a day period is searched for * @return end of day period around given clock time, exclusive * @see #getStart(PlainTime) * @since 3.13/4.10 */ /*[deutsch] * <p>Ermittelt das Ende des Tagesabschnitts, der die angegebene Uhrzeit enthält. </p> * * @param context the clock time a day period is searched for * @return end of day period around given clock time, exclusive * @see #getStart(PlainTime) * @since 3.13/4.10 */ public PlainTime getEnd(PlainTime context) { PlainTime compare = ( (context.getHour() == 24) ? PlainTime.midnightAtStartOfDay() : context); for (PlainTime key : this.codeMap.keySet()) { if (compare.isBefore(key)) { return key; } } return this.codeMap.firstKey(); }
/** * <p>Yields the length of this interval. </p> * * @return duration in hours, minutes, seconds and nanoseconds * @since 2.0 */ /*[deutsch] * <p>Liefert die Länge dieses Intervalls. </p> * * @return duration in hours, minutes, seconds and nanoseconds * @since 2.0 */ public Duration<ClockUnit> getDuration() { PlainTime t1 = this.getTemporalOfClosedStart(); PlainTime t2 = this.getEnd().getTemporal(); if (this.getEnd().isClosed()) { if (t2.getHour() == 24) { if (t1.equals(PlainTime.midnightAtStartOfDay())) { return Duration.of(24, HOURS).plus(1, NANOS); } else { t1 = t1.minus(1, NANOS); } } else { t2 = t2.plus(1, NANOS); } } return Duration.inClockUnits().between(t1, t2); }
private static DaylightSavingRule readLastDayOfWeekPattern(DataInput in) throws IOException, ClassNotFoundException { int first = (in.readByte() & 0xFF); Month month = Month.valueOf(first >>> 4); int offsetInfo = first & 0x0F; OffsetIndicator indicator = OffsetIndicator.VALUES[offsetInfo % 3]; int dst = readSavings(offsetInfo); int second = (in.readByte() & 0xFF); Weekday dayOfWeek = Weekday.valueOf(second >>> 5); int tod = (second & 31); if (dst == -1) { dst = readOffset(in); } if (tod == 31) { tod = in.readInt(); } else { tod *= 3600; } PlainTime timeOfDay = PlainTime.midnightAtStartOfDay().with(SECOND_OF_DAY, tod); return new LastWeekdayPattern( month, dayOfWeek, timeOfDay, indicator, dst); }
if (time.getHour() >= 12) { if (end.isAfter(time) || end.isSimultaneous(PlainTime.midnightAtStartOfDay())) { m = Meridiem.PM; } else if (hour12 != -1) { m = ((hour12 + 12 >= time.getHour()) ? Meridiem.PM : Meridiem.AM); } else if (!end.isAfter(PlainTime.of(12))) { m = Meridiem.AM; } else if (hour12 != -1) { m = ((hour12 >= time.getHour()) ? Meridiem.AM : Meridiem.PM);
PlainTime t2 = end.time; if ((delta > 0) && t1.isAfter(t2)) { delta--; } else if ((delta < 0) && t1.isBefore(t2)) { delta++; MathUtils.safeMultiply(days, 86400), MathUtils.safeSubtract( end.time.get(SECOND_OF_DAY).longValue(), start.time.get(SECOND_OF_DAY).longValue() if (start.time.getNanosecond() > end.time.getNanosecond()) { delta--; MathUtils.safeMultiply(days, 86400L * MRD), MathUtils.safeSubtract( end.time.get(NANO_OF_DAY).longValue(), start.time.get(NANO_OF_DAY).longValue()
if (key.getHour() == 24) { map.put(PlainTime.midnightAtStartOfDay(), timeToLabels.get(key)); map.remove(key); } else if (timeToLabels.get(key).isEmpty()) {
if (dp.isPredefined()) { Map<String, String> textForms = loadTextForms(locale, dp.calendarType); if (time.isMidnight()) { String key = createKey(textForms, this.width, this.outputContext, "midnight"); if (textForms.containsKey(key)) { return textForms.get(key); } else if (time.isSimultaneous(PlainTime.of(12))) { String key = createKey(textForms, this.width, this.outputContext, "noon"); if (textForms.containsKey(key)) { return time.get(PlainTime.AM_PM_OF_DAY).getDisplayName((locale == null) ? Locale.ROOT : locale); // fallback
|| (this.element == DIGITAL_HOUR_OF_AMPM) ) { return context.plus( MathUtils.safeSubtract(value, context.getInt(this.element)), ClockUnit.HOURS); } else if (this.element == MINUTE_OF_HOUR) { return context.plus( MathUtils.safeSubtract(value, context.minute), ClockUnit.MINUTES); } else if (this.element == SECOND_OF_MINUTE) { return context.plus( MathUtils.safeSubtract(value, context.second), ClockUnit.SECONDS); } else if (this.element == MILLI_OF_SECOND) { return context.plus( MathUtils.safeSubtract( value, context.get(MILLI_OF_SECOND)), ClockUnit.MILLIS); } else if (this.element == MICRO_OF_SECOND) { return context.plus( MathUtils.safeSubtract( value, context.get(MICRO_OF_SECOND)), ClockUnit.MICROS); } else if (this.element == NANO_OF_SECOND) { return context.plus( MathUtils.safeSubtract(value, context.nano), ClockUnit.NANOS);
/** * <p>Creates a finite half-open interval between given start time and * midnight at end of day (exclusive). </p> * * <p>Note: The special wall time 24:00 does not belong to the created * interval. </p> * * @param start time of lower boundary (inclusive) * @return new time interval * @since 2.0 */ /*[deutsch] * <p>Erzeugt ein begrenztes halb-offenes Intervall zwischen der * angegebenen Startzeit und Mitternacht zu Ende des Tages (exklusive). </p> * * <p>Zu beachten: Die spezielle Uhrzeit 24:00 gehört nicht zum * erzeugten Intervall. </p> * * @param start time of lower boundary (inclusive) * @return new time interval * @since 2.0 */ public static ClockInterval since(PlainTime start) { return between(start, PlainTime.midnightAtEndOfDay()); }
private PlainTime doApply(PlainTime time) { int hour = time.getHour(); int minute = time.getMinute(); return PlainTime.of(hour); case OP_ROUND_FULL_MINUTE: if (time.getSecond() >= 30) { if (hour == 24) { hour = 0; return PlainTime.of(hour, minute); case OP_NEXT_FULL_HOUR: hour++; hour = 1; return PlainTime.of(hour); case OP_NEXT_FULL_MINUTE: if (hour == 24) { return PlainTime.of(hour, minute); default: throw new AssertionError("Unknown: " + this.getType());
@Override public PlainTimestamp apply(PlainTimestamp entity) { PlainTime oldTime = entity.getWallTime(); if (this.value.isSimultaneous(oldTime)) { return this.handleSameTimes(entity); } else if (this.value.getHour() == 24) { return this.handleMidnight24(entity); } else if (this.value.isAfter(oldTime)) { return this.handleLater(entity); } else { return this.handleEarlier(entity); } }
@Override TimeLine<PlainTime> getTimeLine() { return PlainTime.axis(); }
int hour = Integer.parseInt(key.substring(1, 3)); int minute = Integer.parseInt(key.substring(3, 5)); PlainTime time = PlainTime.midnightAtStartOfDay(); if (hour == 24) { if (minute != 0) { time = time.plus(hour * 60 + minute, ClockUnit.MINUTES); } else { throw new IllegalStateException("Invalid time key: " + key);
private static Moment moveEventuallyToLS(Moment adjusted) { PlainDate date = adjusted.getDateUTC(); PlainTime time = adjusted.getTimeUTC(); if ( (LeapSeconds.getInstance().getShift(date) == 1) && (time.getHour() == 23) && (time.getMinute() == 59) && (time.getSecond() == 59) ) { return adjusted.plus(1, SI.SECONDS); } else { return adjusted; } }
@Override public boolean isAfter(PlainTime time) { return (this.compareTo(time) > 0); }