LocalDateTime ldt = LocalDateTime.of(2015, 3, 29, 2, 30, 0, 0); ZoneRules rules = ZoneId.of("Europe/Berlin").getRules(); ZoneOffsetTransition conflict = rules.getTransition(ldt); if (conflict != null && conflict.isGap()) { ldt = conflict.getDateTimeAfter(); } System.out.println(ldt); // 2015-03-29T03:00
@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; }
offset = validOffsets.get(0); } else if (validOffsets.size() == 0) { ZoneOffsetTransition trans = rules.getTransition(isoLDT); localDateTime = localDateTime.plusSeconds(trans.getDuration().getSeconds()); offset = trans.getOffsetAfter();
@Override public ChronoZonedDateTime<D> withLaterOffsetAtOverlap() { ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this)); if (trans != null) { ZoneOffset offset = trans.getOffsetAfter(); if (offset.equals(getOffset()) == false) { return new ChronoZonedDateTimeImpl<D>(dateTime, offset, zone); } } return this; }
offset = validOffsets.get(0); } else if (validOffsets.size() == 0) { ZoneOffsetTransition trans = rules.getTransition(isoLDT); localDateTime = localDateTime.plusSeconds(trans.getDuration().getSeconds()); offset = trans.getOffsetAfter();
offset = validOffsets.get(0); } else if (validOffsets.size() == 0) { ZoneOffsetTransition trans = rules.getTransition(localDateTime); localDateTime = localDateTime.plusSeconds(trans.getDuration().getSeconds()); offset = trans.getOffsetAfter();
@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; }
offset = validOffsets.get(0); } else if (validOffsets.size() == 0) { ZoneOffsetTransition trans = rules.getTransition(localDateTime); localDateTime = localDateTime.plusSeconds(trans.getDuration().getSeconds()); offset = trans.getOffsetAfter();
@Override public ChronoZonedDateTime<D> withLaterOffsetAtOverlap() { ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this)); if (trans != null) { ZoneOffset offset = trans.getOffsetAfter(); if (offset.equals(getOffset()) == false) { return new ChronoZonedDateTimeImpl<D>(dateTime, offset, 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 * later 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 later 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 later offset, not null */ @Override public ZonedDateTime withLaterOffsetAtOverlap() { ZoneOffsetTransition trans = getZone().getRules().getTransition(toLocalDateTime()); if (trans != null) { ZoneOffset laterOffset = trans.getOffsetAfter(); if (laterOffset.equals(offset) == false) { return new ZonedDateTime(dateTime, laterOffset, 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 * later 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 later 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 later offset, not null */ @Override public ZonedDateTime withLaterOffsetAtOverlap() { ZoneOffsetTransition trans = getZone().getRules().getTransition(toLocalDateTime()); if (trans != null) { ZoneOffset laterOffset = trans.getOffsetAfter(); if (laterOffset.equals(offset) == false) { return new ZonedDateTime(dateTime, laterOffset, zone); } } return this; }
if (zone instanceof ZoneOffset == false) { ZoneRules rules = zone.getRules(); ZoneOffsetTransition trans = rules.getTransition(ldt); if (trans != null && trans.isGap()) { ldt = trans.getDateTimeAfter();
if (zone instanceof ZoneOffset == false) { ZoneRules rules = zone.getRules(); ZoneOffsetTransition trans = rules.getTransition(ldt); if (trans != null && trans.isGap()) { ldt = trans.getDateTimeAfter();
ZoneRules rules = zone.getRules(); if (rules.isValidOffset(localDateTime, offset) == false) { ZoneOffsetTransition trans = rules.getTransition(localDateTime); if (trans != null && trans.isGap()) {
ZoneRules rules = zone.getRules(); if (rules.isValidOffset(localDateTime, offset) == false) { ZoneOffsetTransition trans = rules.getTransition(localDateTime); if (trans != null && trans.isGap()) {