public boolean isExtraHour(final ZonedDateTime time) { final ZoneOffsetTransition dayTransition = time.getZone().getRules() .getTransition(time.toLocalDateTime()); return dayTransition != null && dayTransition.isOverlap() && dayTransition.getInstant() .equals(time.toInstant()); }
@Override public ChronoZonedDateTime<D> withEarlierOffsetAtOverlap() { ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this)); if (trans != null && trans.isOverlap()) { ZoneOffset earlierOffset = trans.getOffsetBefore(); if (earlierOffset.equals(offset) == false) { return new ChronoZonedDateTimeImpl<D>(dateTime, earlierOffset, zone); } } return this; }
@Override public ChronoZonedDateTime<D> withEarlierOffsetAtOverlap() { ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this)); if (trans != null && trans.isOverlap()) { ZoneOffset earlierOffset = trans.getOffsetBefore(); if (earlierOffset.equals(offset) == false) { return new ChronoZonedDateTimeImpl<D>(dateTime, earlierOffset, zone); } } return this; }
/** * Returns a copy of this date-time changing the zone offset to the * earlier of the two valid offsets at a local time-line overlap. * <p> * This method only has any effect when the local time-line overlaps, such as * at an autumn daylight savings cutover. In this scenario, there are two * valid offsets for the local date-time. Calling this method will return * a zoned date-time with the earlier of the two selected. * <p> * If this method is called when it is not an overlap, {@code this} * is returned. * <p> * This instance is immutable and unaffected by this method call. * * @return a {@code ZonedDateTime} based on this date-time with the earlier offset, not null */ @Override public ZonedDateTime withEarlierOffsetAtOverlap() { ZoneOffsetTransition trans = getZone().getRules().getTransition(dateTime); if (trans != null && trans.isOverlap()) { ZoneOffset earlierOffset = trans.getOffsetBefore(); if (earlierOffset.equals(offset) == false) { return new ZonedDateTime(dateTime, earlierOffset, zone); } } return this; }
/** * Returns a copy of this date-time changing the zone offset to the * earlier of the two valid offsets at a local time-line overlap. * <p> * This method only has any effect when the local time-line overlaps, such as * at an autumn daylight savings cutover. In this scenario, there are two * valid offsets for the local date-time. Calling this method will return * a zoned date-time with the earlier of the two selected. * <p> * If this method is called when it is not an overlap, {@code this} * is returned. * <p> * This instance is immutable and unaffected by this method call. * * @return a {@code ZonedDateTime} based on this date-time with the earlier offset, not null */ @Override public ZonedDateTime withEarlierOffsetAtOverlap() { ZoneOffsetTransition trans = getZone().getRules().getTransition(dateTime); if (trans != null && trans.isOverlap()) { ZoneOffset earlierOffset = trans.getOffsetBefore(); if (earlierOffset.equals(offset) == false) { return new ZonedDateTime(dateTime, earlierOffset, zone); } } return this; }