/** * <p>Creates a closed interval between given dates. </p> * * @param start date of lower boundary (inclusive) * @param end date of upper boundary (inclusive) * @return new date interval * @throws IllegalArgumentException if start is after end * @see #between(PlainDate, PlainDate) * @since 4.11 */ /*[deutsch] * <p>Erzeugt ein geschlossenes Intervall zwischen den angegebenen Datumswerten. </p> * * @param start date of lower boundary (inclusive) * @param end date of upper boundary (inclusive) * @return new date interval * @throws IllegalArgumentException if start is after end * @see #between(PlainDate, PlainDate) * @since 4.11 */ public static DateInterval between( LocalDate start, LocalDate end ) { return DateInterval.between(PlainDate.from(start), PlainDate.from(end)); }
/** * <p>Creates a closed interval including only given date. </p> * * @param date single contained date * @return new date interval * @see #atomic(PlainDate) * @since 4.11 */ /*[deutsch] * <p>Erzeugt ein geschlossenes Intervall, das nur das angegebene * Datum enthält. </p> * * @param date single contained date * @return new date interval * @see #atomic(PlainDate) * @since 4.11 */ public static DateInterval atomic(LocalDate date) { return DateInterval.atomic(PlainDate.from(date)); }
/** * <p>Creates an infinite interval since given start date. </p> * * @param start date of lower boundary (inclusive) * @return new date interval * @see #since(PlainDate) * @since 4.11 */ /*[deutsch] * <p>Erzeugt ein unbegrenztes Intervall ab dem angegebenen Startdatum. </p> * * @param start date of lower boundary (inclusive) * @return new date interval * @see #since(PlainDate) * @since 4.11 */ public static DateInterval since(LocalDate start) { return DateInterval.since(PlainDate.from(start)); }
/** * <p>Creates an empty interval with an anchor date. </p> * * @param anchor the anchor date * @return new empty date interval with given anchor date * @see #emptyWithAnchor(PlainDate) * @since 4.37 */ /*[deutsch] * <p>Erzeugt ein leeres Intervall mit einem Ankerdatum. </p> * * @param anchor the anchor date * @return new empty date interval with given anchor date * @see #emptyWithAnchor(PlainDate) * @since 4.37 */ public static DateInterval emptyWithAnchor(LocalDate anchor) { return DateInterval.emptyWithAnchor(PlainDate.from(anchor)); }
/** * <p>Creates an infinite interval until given end date. </p> * * @param end date of upper boundary (inclusive) * @return new date interval * @see #until(PlainDate) * @since 4.11 */ /*[deutsch] * <p>Erzeugt ein unbegrenztes Intervall bis zum angegebenen * Endedatum. </p> * * @param end date of upper boundary (inclusive) * @return new date interval * @see #until(PlainDate) * @since 4.11 */ public static DateInterval until(LocalDate end) { return DateInterval.until(PlainDate.from(end)); }
/** * <p>Converts given gregorian date to a calendar year. </p> * * @param date gregorian calendar date (for example {@code PlainDate} * @return CalendarYear * @throws IllegalArgumentException if given date is invalid * @since 3.28/4.24 */ /*[deutsch] * <p>Konvertiert das angegebene gregorianische Datum zu einem Kalenderjahr. </p> * * @param date gregorian calendar date (for example {@code PlainDate} * @return CalendarYear * @throws IllegalArgumentException if given date is invalid * @since 3.28/4.24 */ public static CalendarYear from(GregorianDate date) { PlainDate iso = PlainDate.from(date); // includes validation return CalendarYear.of(iso.getYear()); }
/** * <p>Ermittelt das aktuelle Datum in der assoziierten Zeitzone. </p> * * <p>Das Ergebnis hängt genau dann dynamisch von der assoziierten Zeitzone ab, wenn die * System-Zeitzone vorliegt. </p> * * @return calendar date representing today */ public PlainDate today() { final UnixTime ut = this.timeSource.currentTime(); Timezone tz = (this.timezone == null) ? Timezone.ofSystem() : this.timezone; return PlainDate.from(ut, tz.getOffset(ut)); }
/** * <p>Converts given gregorian date to a calendar month. </p> * * @param date gregorian calendar date (for example {@code PlainDate} * @return CalendarMonth * @throws IllegalArgumentException if given date is invalid * @since 3.28/4.24 */ /*[deutsch] * <p>Konvertiert das angegebene gregorianische Datum zu einem Kalendermonat. </p> * * @param date gregorian calendar date (for example {@code PlainDate} * @return CalendarMonth * @throws IllegalArgumentException if given date is invalid * @since 3.28/4.24 */ public static CalendarMonth from(GregorianDate date) { PlainDate iso = PlainDate.from(date); // includes validation return CalendarMonth.of(iso.getYear(), iso.getMonth()); }
/** * <p>Converts given gregorian date to a quarter year. </p> * * @param date gregorian calendar date (for example {@code PlainDate} * @return CalendarQuarter * @throws IllegalArgumentException if given date is invalid * @since 3.28/4.24 */ /*[deutsch] * <p>Konvertiert das angegebene gregorianische Datum zu einem Kalenderquartal. </p> * * @param date gregorian calendar date (for example {@code PlainDate} * @return CalendarQuarter * @throws IllegalArgumentException if given date is invalid * @since 3.28/4.24 */ public static CalendarQuarter from(GregorianDate date) { PlainDate iso = PlainDate.from(date); // includes validation return CalendarQuarter.of(iso.getYear(), iso.get(PlainDate.QUARTER_OF_YEAR)); }
/** * <p>Converts given gregorian date to a calendar week. </p> * * @param date gregorian calendar date (for example {@code PlainDate} * @return CalendarWeek * @throws IllegalArgumentException if given date is invalid * @since 3.28/4.24 */ /*[deutsch] * <p>Konvertiert das angegebene gregorianische Datum zu einer Kalenderwoche. </p> * * @param date gregorian calendar date (for example {@code PlainDate} * @return CalendarWeek * @throws IllegalArgumentException if given date is invalid * @since 3.28/4.24 */ public static CalendarWeek from(GregorianDate date) { PlainDate iso = PlainDate.from(date); // includes validation return CalendarWeek.of(iso.getInt(PlainDate.YEAR_OF_WEEKDATE), iso.getInt(Weekmodel.ISO.weekOfYear())); }
@Override public PlainDate createFrom( TimeSource<?> clock, AttributeQuery attributes ) { Timezone zone; if (attributes.contains(Attributes.TIMEZONE_ID)) { zone = Timezone.of(attributes.get(Attributes.TIMEZONE_ID)); } else if (attributes.get(Attributes.LENIENCY, Leniency.SMART).isLax()) { zone = Timezone.ofSystem(); } else { return null; } final UnixTime ut = clock.currentTime(); return PlainDate.from(ut, zone.getOffset(ut)); }
@Override public Moment apply(Moment timepoint) { LeapSeconds ls = LeapSeconds.getInstance(); if (ls.isEnabled()) { long utc = timepoint.getElapsedTime(TimeScale.UTC); LeapSecondEvent event = ls.getNextEvent(utc); if (event != null) { PlainTimestamp tsp = PlainDate.from(event.getDate()).atTime(23, 59, 59); return tsp.atUTC().plus(event.getShift(), SECONDS); } } return null; }