public int compareTo(TZRule other) { int cmp = year - other.year; cmp = (cmp == 0 ? month.compareTo(other.month) : cmp); if (cmp == 0) { // convert to date to handle dow/domIndicator/timeEndOfDay LocalDate thisDate = toLocalDate(); LocalDate otherDate = other.toLocalDate(); cmp = thisDate.compareTo(otherDate); } if (cmp != 0) { return cmp; } long timeSecs1 = time.toSecondOfDay() + adjustDays * 86400; long timeSecs2 = other.time.toSecondOfDay() + other.adjustDays * 86400; return timeSecs1 < timeSecs2 ? -1 : (timeSecs1 > timeSecs2 ? 1 : 0); }
public int compareTo(TZRule other) { int cmp = year - other.year; cmp = (cmp == 0 ? month.compareTo(other.month) : cmp); if (cmp == 0) { // convert to date to handle dow/domIndicator/timeEndOfDay LocalDate thisDate = toLocalDate(); LocalDate otherDate = other.toLocalDate(); cmp = thisDate.compareTo(otherDate); } if (cmp != 0) { return cmp; } long timeSecs1 = time.toSecondOfDay() + adjustDays * 86400; long timeSecs2 = other.time.toSecondOfDay() + other.adjustDays * 86400; return timeSecs1 < timeSecs2 ? -1 : (timeSecs1 > timeSecs2 ? 1 : 0); }
buf.append(time); } else { long timeOfDaysMins = time.toSecondOfDay() / 60 + adjustDays * 24 * 60; appendZeroPad(buf, Jdk8Methods.floorDiv(timeOfDaysMins, 60)); buf.append(':');
buf.append(time); } else { long timeOfDaysMins = time.toSecondOfDay() / 60 + adjustDays * 24 * 60; appendZeroPad(buf, Jdk8Methods.floorDiv(timeOfDaysMins, 60)); buf.append(':');
private int get0(TemporalField field) { switch ((ChronoField) field) { case NANO_OF_SECOND: return nano; case NANO_OF_DAY: throw new DateTimeException("Field too large for an int: " + field); case MICRO_OF_SECOND: return nano / 1000; case MICRO_OF_DAY: throw new DateTimeException("Field too large for an int: " + field); case MILLI_OF_SECOND: return nano / 1000000; case MILLI_OF_DAY: return (int) (toNanoOfDay() / 1000000); case SECOND_OF_MINUTE: return second; case SECOND_OF_DAY: return toSecondOfDay(); case MINUTE_OF_HOUR: return minute; case MINUTE_OF_DAY: return hour * 60 + minute; case HOUR_OF_AMPM: return hour % 12; case CLOCK_HOUR_OF_AMPM: int ham = hour % 12; return (ham % 12 == 0 ? 12 : ham); case HOUR_OF_DAY: return hour; case CLOCK_HOUR_OF_DAY: return (hour == 0 ? 24 : hour); case AMPM_OF_DAY: return hour / 12; } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); }
private void mergeInstantFields0(ZoneId selectedZone) { Instant instant = Instant.ofEpochSecond(fieldValues.remove(INSTANT_SECONDS)); ChronoZonedDateTime<?> zdt = chrono.zonedDateTime(instant, selectedZone); if (date == null) { addObject(zdt.toLocalDate()); } else { resolveMakeChanges(INSTANT_SECONDS, zdt.toLocalDate()); } addFieldValue(SECOND_OF_DAY, (long) zdt.toLocalTime().toSecondOfDay()); }
private int get0(TemporalField field) { switch ((ChronoField) field) { case NANO_OF_SECOND: return nano; case NANO_OF_DAY: throw new DateTimeException("Field too large for an int: " + field); case MICRO_OF_SECOND: return nano / 1000; case MICRO_OF_DAY: throw new DateTimeException("Field too large for an int: " + field); case MILLI_OF_SECOND: return nano / 1000000; case MILLI_OF_DAY: return (int) (toNanoOfDay() / 1000000); case SECOND_OF_MINUTE: return second; case SECOND_OF_DAY: return toSecondOfDay(); case MINUTE_OF_HOUR: return minute; case MINUTE_OF_DAY: return hour * 60 + minute; case HOUR_OF_AMPM: return hour % 12; case CLOCK_HOUR_OF_AMPM: int ham = hour % 12; return (ham % 12 == 0 ? 12 : ham); case HOUR_OF_DAY: return hour; case CLOCK_HOUR_OF_DAY: return (hour == 0 ? 24 : hour); case AMPM_OF_DAY: return hour / 12; } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); }
final int timeSecs = time.toSecondOfDay() + adjustDays * SECS_PER_DAY; final int stdOffset = standardOffset.getTotalSeconds(); final int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset;
private void mergeInstantFields0(ZoneId selectedZone) { Instant instant = Instant.ofEpochSecond(fieldValues.remove(INSTANT_SECONDS)); ChronoZonedDateTime<?> zdt = chrono.zonedDateTime(instant, selectedZone); if (date == null) { addObject(zdt.toLocalDate()); } else { resolveMakeChanges(INSTANT_SECONDS, zdt.toLocalDate()); } addFieldValue(SECOND_OF_DAY, (long) zdt.toLocalTime().toSecondOfDay()); }
final int timeSecs = time.toSecondOfDay() + adjustDays * SECS_PER_DAY; final int stdOffset = standardOffset.getTotalSeconds(); final int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset;
/** * Returns a suitable hash code. * * @return the hash code */ @Override public int hashCode() { int hash = ((time.toSecondOfDay() + adjustDays) << 15) + (month.ordinal() << 11) + ((dom + 32) << 5) + ((dow == null ? 7 : dow.ordinal()) << 2) + (timeDefinition.ordinal()); return hash ^ standardOffset.hashCode() ^ offsetBefore.hashCode() ^ offsetAfter.hashCode(); }
/** * Converts this date-time to the number of seconds from the epoch * of 1970-01-01T00:00:00Z. * <p> * This combines this local date-time and the specified offset to calculate the * epoch-second value, which is the number of elapsed seconds from 1970-01-01T00:00:00Z. * Instants on the time-line after the epoch are positive, earlier are negative. * * @param offset the offset to use for the conversion, not null * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z */ public long toEpochSecond(ZoneOffset offset) { Jdk8Methods.requireNonNull(offset, "offset"); long epochDay = toLocalDate().toEpochDay(); long secs = epochDay * 86400 + toLocalTime().toSecondOfDay(); secs -= offset.getTotalSeconds(); return secs; }
/** * Returns a suitable hash code. * * @return the hash code */ @Override public int hashCode() { int hash = ((time.toSecondOfDay() + adjustDays) << 15) + (month.ordinal() << 11) + ((dom + 32) << 5) + ((dow == null ? 7 : dow.ordinal()) << 2) + (timeDefinition.ordinal()); return hash ^ standardOffset.hashCode() ^ offsetBefore.hashCode() ^ offsetAfter.hashCode(); }
/** * Converts this date-time to the number of seconds from the epoch * of 1970-01-01T00:00:00Z. * <p> * This uses the {@linkplain #toLocalDateTime() local date-time} and * {@linkplain #getOffset() offset} to calculate the epoch-second value, * which is the number of elapsed seconds from 1970-01-01T00:00:00Z. * Instants on the time-line after the epoch are positive, earlier are negative. * * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z */ public long toEpochSecond() { long epochDay = toLocalDate().toEpochDay(); long secs = epochDay * 86400 + toLocalTime().toSecondOfDay(); secs -= getOffset().getTotalSeconds(); return secs; }
/** * Converts this date-time to the number of seconds from the epoch * of 1970-01-01T00:00:00Z. * <p> * This uses the {@linkplain #toLocalDateTime() local date-time} and * {@linkplain #getOffset() offset} to calculate the epoch-second value, * which is the number of elapsed seconds from 1970-01-01T00:00:00Z. * Instants on the time-line after the epoch are positive, earlier are negative. * * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z */ public long toEpochSecond() { long epochDay = toLocalDate().toEpochDay(); long secs = epochDay * 86400 + toLocalTime().toSecondOfDay(); secs -= getOffset().getTotalSeconds(); return secs; }
/** * Converts this date-time to the number of seconds from the epoch * of 1970-01-01T00:00:00Z. * <p> * This combines this local date-time and the specified offset to calculate the * epoch-second value, which is the number of elapsed seconds from 1970-01-01T00:00:00Z. * Instants on the time-line after the epoch are positive, earlier are negative. * * @param offset the offset to use for the conversion, not null * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z */ public long toEpochSecond(ZoneOffset offset) { Jdk8Methods.requireNonNull(offset, "offset"); long epochDay = toLocalDate().toEpochDay(); long secs = epochDay * 86400 + toLocalTime().toSecondOfDay(); secs -= offset.getTotalSeconds(); return secs; }
case MILLI_OF_DAY: return LocalTime.ofNanoOfDay(newValue * 1000000); case SECOND_OF_MINUTE: return withSecond((int) newValue); case SECOND_OF_DAY: return plusSeconds(newValue - toSecondOfDay()); case MINUTE_OF_HOUR: return withMinute((int) newValue); case MINUTE_OF_DAY: return plusMinutes(newValue - (hour * 60 + minute));
case MILLI_OF_DAY: return LocalTime.ofNanoOfDay(newValue * 1000000); case SECOND_OF_MINUTE: return withSecond((int) newValue); case SECOND_OF_DAY: return plusSeconds(newValue - toSecondOfDay()); case MINUTE_OF_HOUR: return withMinute((int) newValue); case MINUTE_OF_DAY: return plusMinutes(newValue - (hour * 60 + minute));