/** * <p>Creates a new local timestamp with this date and given wall time. </p> * * <p>If the time {@link PlainTime#midnightAtEndOfDay() T24:00} is used * then the resulting timestamp will automatically be normalized such * that the timestamp will contain the following day instead. </p> * * @param time wall time * @return local timestamp as composition of this date and given time */ /*[deutsch] * <p>Erzeugt einen lokalen Zeitstempel mit diesem Datum und der * angegebenen Uhrzeit. </p> * * <p>Wenn {@link PlainTime#midnightAtEndOfDay() T24:00} angegeben wird, * dann wird der Zeitstempel automatisch so normalisiert, daß er auf * den nächsten Tag verweist. </p> * * @param time wall time * @return local timestamp as composition of this date and given time */ public PlainTimestamp at(PlainTime time) { return PlainTimestamp.of(this, time); }
) { return PlainTimestamp.of(year, month, dayOfMonth, hour, minute, 0);
@Override public PlainTimestamp withValue( PlainTimestamp context, BigDecimal value, boolean lenient ) { if (!this.isValid(context, value)) { throw new IllegalArgumentException("Out of range: " + value); } PlainTime time = context.time.with(super.element, value); return PlainTimestamp.of(context.date, time); }
private Object readTimestamp( DataInput in, byte header ) throws IOException, ClassNotFoundException { PlainDate date = readDate(in, header); PlainTime time = readTime(in); return PlainTimestamp.of(date, time); }
@Override public PlainTimestamp addTo(PlainTimestamp tsp, long amount) { PlainDate date = dateRule.addTo(tsp.toDate(), amount); return PlainTimestamp.of(date, tsp.toTime()); } @Override
@Override public PlainTimestamp createFrom( TemporalAccessor threeten, AttributeQuery attributes ) { PlainDate date = PlainDate.axis().createFrom(threeten, attributes); PlainTime time = PlainTime.axis().createFrom(threeten, attributes); if ((date != null) && (time != null)) { return PlainTimestamp.of(date, time); } return null; }
@Override public PlainTimestamp withValue( PlainTimestamp context, int value, boolean lenient ) { if (value == this.getInt(context)) { return context; } else if (lenient) { // nur auf numerischen Elementen definiert IsoUnit unit = ENGINE.getBaseUnit(this.element); long amount = MathUtils.safeSubtract((long) value, this.getInt(context)); return context.plus(amount, unit); } else if (this.element.isDateElement()) { PlainDate date = context.date.with(this.element, value); return PlainTimestamp.of(date, context.time); } else if (this.element.isTimeElement()) { int min = this.element.getDefaultMinimum().intValue(); int max = this.element.getDefaultMaximum().intValue(); if ((min > value) || (max < value)) { throw new IllegalArgumentException("Out of range: " + value); } PlainTime time = context.time.with(this.element, value); return PlainTimestamp.of(context.date, time); } throw new ChronoException( "Missing rule for: " + this.element.name()); }
@Override public PlainTimestamp addTo( PlainTimestamp timepoint, long amount ) { PlainDate d; PlainTime t; if (this.calendarUnit != null) { d = timepoint.date.plus(amount, this.calendarUnit); t = timepoint.time; } else { DayCycles cycles = timepoint.time.roll(amount, this.clockUnit); d = timepoint.date.plus(cycles.getDayOverflow(), DAYS); t = cycles.getWallTime(); } return PlainTimestamp.of(d, t); }
private FullValueOperator(int type) { super(PlainTime.COMPONENT, type); this.tsop = entity -> { PlainTime time = doApply(entity.getWallTime()); if (time.getHour() == 24) { return PlainTimestamp.of( entity.getCalendarDate().plus(1, DAYS), PlainTime.midnightAtStartOfDay()); } else { return entity.with(time); } }; }
@Override public PlainTimestamp translate(java.sql.Timestamp source) { long millis = source.getTime(); // UTC zone if (!WITH_SQL_UTC_CONVERSION) { Moment unixTime = Moment.of( MathUtils.floorDivide(millis, 1000), TimeScale.POSIX); ZonalOffset offset = Timezone.ofSystem().getOffset(unixTime); millis += offset.getIntegralAmount() * 1000; } PlainDate date = PlainDate.of( MathUtils.floorDivide(millis, 86400 * 1000), EpochDays.UNIX); PlainTime time = PlainTime.of(0).plus( MathUtils.floorModulo(millis, 86400 * 1000), ClockUnit.MILLIS); PlainTimestamp ts = PlainTimestamp.of(date, time); return ts.with(PlainTime.NANO_OF_SECOND, source.getNanos()); }
@Override public PlainTimestamp translate(LocalDateTime source) { return PlainTimestamp.of( PlainDate.of(source.getYear(), source.getMonthValue(), source.getDayOfMonth()), PlainTime.of(source.getHour(), source.getMinute(), source.getSecond(), source.getNano()) ); }
private PlainTimestamp atStartOfDay(TransitionHistory history) { if (history == null) { throw new UnsupportedOperationException( "Timezone repository does not expose its transition history: " + Timezone.getProviderInfo()); } ZonalTransition conflict = history.getConflictTransition(this, PlainTime.MIN); if ((conflict != null) && conflict.isGap()) { long localSeconds = conflict.getPosixTime() + conflict.getTotalOffset(); PlainDate date = PlainDate.of( MathUtils.floorDivide(localSeconds, 86400), EpochDays.UNIX); int secondsOfDay = MathUtils.floorModulo(localSeconds, 86400); int second = secondsOfDay % 60; int minutesOfDay = secondsOfDay / 60; int minute = minutesOfDay % 60; int hour = minutesOfDay / 60; PlainTime time = PlainTime.of(hour, minute, second); return PlainTimestamp.of(date, time); } return this.at(PlainTime.MIN); }
); return PlainTimestamp.of(date, time);
return PlainTimestamp.of(date, time);
) { return PlainTimestamp.of( PlainDate.of(year, month, dayOfMonth), PlainTime.of(hour, minute, second)