MenoData / Time4J

Advanced date, time and interval library for Java with sun/moon-astronomy and calendars like Chinese, Coptic, Ethiopian, French Republican, Hebrew, Hijri, Historic Christian, Indian National, Japanese, Julian, Korean, Minguo, Persian, Thai, Vietnamese
GNU Lesser General Public License v2.1
442 stars 65 forks source link

v4.11: Define convenient methods for creating intervals using JSR-310-types #433

Closed MenoData closed 8 years ago

MenoData commented 8 years ago

Some people would like to have the option to create intervals of various boundary styles (closed, half-open, open, infinite) using JSR-310-types, see also

https://github.com/ThreeTen/threeten-extra/issues/53

Code examples:

Instant instant = ...;
MomentInterval mi = MomentInterval.until(instant);

LocalDateTime start = ...;
LocalDateTime end = ...;
TimestampInterval ti = TimestampInterval.between(start, end);
MenoData commented 8 years ago

DateInterval got following new methods:

public static DateInterval.between(LocalDate, LocalDate);
public static DateInterval.since(LocalDate);
public static DateInterval.until(LocalDate);
public static DateInterval.atomic(LocalDate);
public PlainDate getStartAsCalendarDate();
public LocalDate getStartAsLocalDate();
public PlainDate getEndAsCalendarDate();
public LocalDate getEndAsLocalDate();

ClockInterval got following new methods:

public static ClockInterval.between(LocalTime, LocalTime);
public static ClockInterval.since(LocalTime);
public static ClockInterval.until(LocalTime);
public PlainTime getStartAsClockTime();
public LocalTime getStartAsLocalTime();
public PlainTime getEndAsClockTime();
public LocalTime getEndAsLocalTime();

TimestampInterval got following new methods:

public static TimestampInterval.between(LocalDateTime, LocalDateTime);
public static TimestampInterval.since(LocalDateTime);
public static TimestampInterval.until(LocalDateTime);
public PlainTimestamp getStartAsTimestamp();
public LocalDateTime getStartAsLocalDateTime();
public PlainTimestamp getEndAsTimestamp();
public LocalDateTime getEndAsLocalDateTime();

MomentInterval got following new methods:

public static MomentInterval.between(Instant, Instant);
public static MomentInterval.since(Instant);
public static MomentInterval.until(Instant);
public Moment getStartAsMoment();
public Instant getStartAsInstant();
public Moment getEndAsMoment();
public Instant getEndAsInstant();