@Test public void zonedDateTimeTest() { assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.1-06,)")); assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.12-06,)")); assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.123-06,)")); assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.1234-06,)")); assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.12345-06,)")); assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.123456-06,)")); assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.123456-06,infinity)")); }
public static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr) { Range<ZonedDateTime> range = ofString(rangeStr, parseZonedDateTime().compose(unquote()), ZonedDateTime.class); if (range.hasLowerBound() && range.hasUpperBound()) { ZoneId lowerZone = range.lower().getZone(); ZoneId upperZone = range.upper().getZone(); if (!lowerZone.equals(upperZone)) { Duration lowerDst = ZoneId.systemDefault().getRules().getDaylightSavings(range.lower().toInstant()); Duration upperDst = ZoneId.systemDefault().getRules().getDaylightSavings(range.upper().toInstant()); long dstSeconds = upperDst.minus(lowerDst).getSeconds(); if(dstSeconds < 0 ) { dstSeconds *= -1; } long zoneDriftSeconds = ((ZoneOffset) lowerZone).getTotalSeconds() - ((ZoneOffset) upperZone).getTotalSeconds(); if (zoneDriftSeconds < 0) { zoneDriftSeconds *= -1; } if (dstSeconds != zoneDriftSeconds) { throw new IllegalArgumentException("The upper and lower bounds must be in same time zone!"); } } } return range; }
Range implements Serializable { public static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr) { Range<ZonedDateTime> range = ofString(rangeStr, parseZonedDateTime().compose(unquote()), ZonedDateTime.class); if (range.hasLowerBound() && range.hasUpperBound()) { ZoneId lowerZone = range.lower().getZone(); ZoneId upperZone = range.upper().getZone(); if (!lowerZone.equals(upperZone)) { Duration lowerDst = ZoneId.systemDefault().getRules().getDaylightSavings(range.lower().toInstant()); Duration upperDst = ZoneId.systemDefault().getRules().getDaylightSavings(range.upper().toInstant()); long dstSeconds = upperDst.minus(lowerDst).getSeconds(); if(dstSeconds < 0 ) { dstSeconds *= -1; } long zoneDriftSeconds = ((ZoneOffset) lowerZone).getTotalSeconds() - ((ZoneOffset) upperZone).getTotalSeconds(); if (zoneDriftSeconds < 0) { zoneDriftSeconds *= -1; } if (dstSeconds != zoneDriftSeconds) { throw new IllegalArgumentException("The upper and lower bounds must be in same time zone!"); } } } return range; } }
Range implements Serializable { public static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr) { Range<ZonedDateTime> range = ofString(rangeStr, parseZonedDateTime().compose(unquote()), ZonedDateTime.class); if (range.hasLowerBound() && range.hasUpperBound()) { ZoneId lowerZone = range.lower().getZone(); ZoneId upperZone = range.upper().getZone(); if (!lowerZone.equals(upperZone)) { Duration lowerDst = ZoneId.systemDefault().getRules().getDaylightSavings(range.lower().toInstant()); Duration upperDst = ZoneId.systemDefault().getRules().getDaylightSavings(range.upper().toInstant()); long dstSeconds = upperDst.minus(lowerDst).getSeconds(); if(dstSeconds < 0 ) { dstSeconds *= -1; } long zoneDriftSeconds = ((ZoneOffset) lowerZone).getTotalSeconds() - ((ZoneOffset) upperZone).getTotalSeconds(); if (zoneDriftSeconds < 0) { zoneDriftSeconds *= -1; } if (dstSeconds != zoneDriftSeconds) { throw new IllegalArgumentException("The upper and lower bounds must be in same time zone!"); } } } return range; } private  Range(T lower, T upper, int mask, Class<T> clazz); }
Range implements Serializable { public static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr) { Range<ZonedDateTime> range = ofString(rangeStr, parseZonedDateTime().compose(unquote()), ZonedDateTime.class); if (range.hasLowerBound() && range.hasUpperBound()) { ZoneId lowerZone = range.lower().getZone(); ZoneId upperZone = range.upper().getZone(); if (!lowerZone.equals(upperZone)) { Duration lowerDst = ZoneId.systemDefault().getRules().getDaylightSavings(range.lower().toInstant()); Duration upperDst = ZoneId.systemDefault().getRules().getDaylightSavings(range.upper().toInstant()); long dstSeconds = upperDst.minus(lowerDst).getSeconds(); if(dstSeconds < 0 ) { dstSeconds *= -1; } long zoneDriftSeconds = ((ZoneOffset) lowerZone).getTotalSeconds() - ((ZoneOffset) upperZone).getTotalSeconds(); if (zoneDriftSeconds < 0) { zoneDriftSeconds *= -1; } if (dstSeconds != zoneDriftSeconds) { throw new IllegalArgumentException("The upper and lower bounds must be in same time zone!"); } } } return range; } private  Range(T lower, T upper, int mask, Class<T> clazz); @SuppressWarnings("unchecked") static Range<T> closed(T lower, T upper); @SuppressWarnings("unchecked") static Range<T> open(T lower, T upper); @SuppressWarnings("unchecked") static Range<T> openClosed(T lower, T upper); @SuppressWarnings("unchecked") static Range<T> closedOpen(T lower, T upper); @SuppressWarnings("unchecked") static Range<T> openInfinite(T lower); @SuppressWarnings("unchecked") static Range<T> closedInfinite(T lower); @SuppressWarnings("unchecked") static Range<T> infiniteOpen(T upper); @SuppressWarnings("unchecked") static Range<T> infiniteClosed(T upper); @SuppressWarnings("unchecked") static Range<T> infinite(Class<T> cls); @SuppressWarnings("unchecked") static Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz); static Range<BigDecimal> bigDecimalRange(String range); static Range<Integer> integerRange(String range); static Range<Long> longRange(String range); static Range<LocalDateTime> localDateTimeRange(String range); static Range<LocalDate> localDateRange(String range); static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean hasMask(int flag); boolean isLowerBoundClosed(); boolean isUpperBoundClosed(); boolean hasLowerBound(); boolean hasUpperBound(); T lower(); T upper(); @SuppressWarnings("unchecked") boolean contains(T point); boolean contains(Range<T> range); String asString(); static Range<R> emptyRange(Class<R> clazz); }
Range implements Serializable { public static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr) { Range<ZonedDateTime> range = ofString(rangeStr, parseZonedDateTime().compose(unquote()), ZonedDateTime.class); if (range.hasLowerBound() && range.hasUpperBound()) { ZoneId lowerZone = range.lower().getZone(); ZoneId upperZone = range.upper().getZone(); if (!lowerZone.equals(upperZone)) { Duration lowerDst = ZoneId.systemDefault().getRules().getDaylightSavings(range.lower().toInstant()); Duration upperDst = ZoneId.systemDefault().getRules().getDaylightSavings(range.upper().toInstant()); long dstSeconds = upperDst.minus(lowerDst).getSeconds(); if(dstSeconds < 0 ) { dstSeconds *= -1; } long zoneDriftSeconds = ((ZoneOffset) lowerZone).getTotalSeconds() - ((ZoneOffset) upperZone).getTotalSeconds(); if (zoneDriftSeconds < 0) { zoneDriftSeconds *= -1; } if (dstSeconds != zoneDriftSeconds) { throw new IllegalArgumentException("The upper and lower bounds must be in same time zone!"); } } } return range; } private  Range(T lower, T upper, int mask, Class<T> clazz); @SuppressWarnings("unchecked") static Range<T> closed(T lower, T upper); @SuppressWarnings("unchecked") static Range<T> open(T lower, T upper); @SuppressWarnings("unchecked") static Range<T> openClosed(T lower, T upper); @SuppressWarnings("unchecked") static Range<T> closedOpen(T lower, T upper); @SuppressWarnings("unchecked") static Range<T> openInfinite(T lower); @SuppressWarnings("unchecked") static Range<T> closedInfinite(T lower); @SuppressWarnings("unchecked") static Range<T> infiniteOpen(T upper); @SuppressWarnings("unchecked") static Range<T> infiniteClosed(T upper); @SuppressWarnings("unchecked") static Range<T> infinite(Class<T> cls); @SuppressWarnings("unchecked") static Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz); static Range<BigDecimal> bigDecimalRange(String range); static Range<Integer> integerRange(String range); static Range<Long> longRange(String range); static Range<LocalDateTime> localDateTimeRange(String range); static Range<LocalDate> localDateRange(String range); static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean hasMask(int flag); boolean isLowerBoundClosed(); boolean isUpperBoundClosed(); boolean hasLowerBound(); boolean hasUpperBound(); T lower(); T upper(); @SuppressWarnings("unchecked") boolean contains(T point); boolean contains(Range<T> range); String asString(); static Range<R> emptyRange(Class<R> clazz); static final int LOWER_INCLUSIVE; static final int LOWER_EXCLUSIVE; static final int UPPER_INCLUSIVE; static final int UPPER_EXCLUSIVE; static final int LOWER_INFINITE; static final int UPPER_INFINITE; static final String EMPTY; static final String INFINITY; }