/** * <p>Creates a finite half-open interval between given time points. </p> * * @param start timestamp of lower boundary (inclusive) * @param end timestamp of upper boundary (exclusive) * @return new timestamp interval * @throws IllegalArgumentException if start is after end * @see #between(PlainTimestamp, PlainTimestamp) * @since 4.11 */ /*[deutsch] * <p>Erzeugt ein begrenztes halb-offenes Intervall zwischen den * angegebenen Zeitpunkten. </p> * * @param start timestamp of lower boundary (inclusive) * @param end timestamp of upper boundary (exclusive) * @return new timestamp interval * @throws IllegalArgumentException if start is after end * @see #between(PlainTimestamp, PlainTimestamp) * @since 4.11 */ public static TimestampInterval between( LocalDateTime start, LocalDateTime end ) { return TimestampInterval.between(PlainTimestamp.from(start), PlainTimestamp.from(end)); }
private PlainTimestamp in(Timezone tz) { return PlainTimestamp.from(this, tz.getOffset(this)); }
/** * <p>Creates an infinite open interval until given end timestamp. </p> * * @param end timestamp of upper boundary (exclusive) * @return new timestamp interval * @see #until(PlainTimestamp) * @since 4.11 */ /*[deutsch] * <p>Erzeugt ein unbegrenztes offenes Intervall bis zum angegebenen * Endzeitpunkt. </p> * * @param end timestamp of upper boundary (exclusive) * @return new timestamp interval * @see #until(PlainTimestamp) * @since 4.11 */ public static TimestampInterval until(LocalDateTime end) { return TimestampInterval.until(PlainTimestamp.from(end)); }
/** * <p>Creates an infinite half-open interval since given start * timestamp. </p> * * @param start timestamp of lower boundary (inclusive) * @return new timestamp interval * @see #since(PlainTimestamp) * @since 4.11 */ /*[deutsch] * <p>Erzeugt ein unbegrenztes halb-offenes Intervall ab dem angegebenen * Startzeitpunkt. </p> * * @param start timestamp of lower boundary (inclusive) * @return new timestamp interval * @see #since(PlainTimestamp) * @since 4.11 */ public static TimestampInterval since(LocalDateTime start) { return TimestampInterval.since(PlainTimestamp.from(start)); }
@Override public V apply(Moment context) { ZonalOffset shift = ( (this.offset == null) ? this.tz.getOffset(context) : this.offset); if ( (this.element == PlainTime.SECOND_OF_MINUTE) && context.isLeapSecond() && (shift.getFractionalAmount() == 0) && ((shift.getAbsoluteSeconds() % 60) == 0) ) { return this.element.getType().cast(Integer.valueOf(60)); } return PlainTimestamp.from(context, shift).get(this.element); }
private ZonalDateTime( Moment moment, Timezone tz ) { super(); this.zone = tz; ZonalOffset offset = tz.getOffset(moment); if (moment.isLeapSecond()) { if ( (offset.getFractionalAmount() != 0) || ((offset.getAbsoluteSeconds() % 60) != 0) ) { throw new IllegalArgumentException( "Leap second can only be represented " + " with timezone-offset in full minutes: " + offset); } } this.moment = moment; this.timestamp = PlainTimestamp.from(moment, offset); }
/** * <p>Gets the current timestamp in the associated timezone. </p> * * <p>The result dynamically depends on the associated timezone meaning if and only if the underlying * timezone is the system timezone. </p> * * @return current local timestamp */ /*[deutsch] * <p>Ermittelt die aktuelle Zeit 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 current local timestamp */ public PlainTimestamp now() { final UnixTime ut = this.timeSource.currentTime(); Timezone tz = (this.timezone == null) ? Timezone.ofSystem() : this.timezone; return PlainTimestamp.from(ut, tz.getOffset(ut)); }
@Override public PlainTimestamp createFrom( TimeSource<?> clock, final 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 PlainTimestamp.from(ut, zone.getOffset(ut)); }