@Override public long getPosixTime() { return this.moment.getPosixTime(); }
@Override public Long getValue(Moment context) { return Long.valueOf(context.getPosixTime()); }
@Override public Instant from(Moment moment) { return Instant.ofEpochSecond(moment.getPosixTime(), moment.getNanosecond()); }
@Override public java.sql.Timestamp from(Moment moment) { java.sql.Timestamp sql = new java.sql.Timestamp(MathUtils.safeMultiply(moment.getPosixTime(), 1000)); sql.setNanos(moment.getNanosecond()); return sql; }
@Override public Date from(Moment target) { long posixTime = target.getPosixTime(); int fraction = target.getNanosecond(); long millis = MathUtils.safeAdd( MathUtils.safeMultiply(posixTime, 1000), fraction / MIO); return new Date(millis); }
@Override public Long from(Moment moment) { long posixTime = moment.getPosixTime(); int fraction = moment.getNanosecond(); return Long.valueOf( MathUtils.safeAdd( MathUtils.safeMultiply(posixTime, 1000), fraction / MIO)); }
private String printRelativeSeconds( Moment t1, Moment t2, long delta ) { if (t1.getPosixTime() >= START_1972 && t2.getPosixTime() >= START_1972) { delta = SI.SECONDS.between(t1, t2); // leap second correction } if (delta == 0) { return UnitPatterns.of(this.locale).getNowWord(); } long amount = Math.abs(delta); String pattern = ( (delta < 0) ? this.getPastPattern(amount, ClockUnit.SECONDS) : this.getFuturePattern(amount, ClockUnit.SECONDS)); return this.format(pattern, amount); }
@Override public Moment withValue( Moment context, Integer value, boolean lenient ) { if (value == null) { throw new IllegalArgumentException("Missing fraction value."); } if (LeapSeconds.getInstance().isEnabled()) { return Moment.of( context.getElapsedTime(TimeScale.UTC), value.intValue(), TimeScale.UTC); } else { return Moment.of( context.getPosixTime(), value.intValue(), TimeScale.POSIX); } }
private static long getTransitionTime( DaylightSavingRule rule, int year, int shift ) { PlainTimestamp tsp = rule.getDate(year).at(rule.getTimeOfDay()); return tsp.at(ZonalOffset.ofTotalSeconds(shift)).getPosixTime(); }
delta = (end.getPosixTime() - start.getPosixTime()); if (delta < 0) { if (end.getNanosecond() > start.getNanosecond()) { Math.multiplyExact( Math.subtractExact( end.getPosixTime(), start.getPosixTime() ), MRD
Moment.axis().getMinimum().getPosixTime(), initial.getStandardOffset(), initial.getStandardOffset(),
@Override public Moment addTo( Moment context, long amount ) { if (this.unit.compareTo(TimeUnit.SECONDS) >= 0) { long secs = Math.multiplyExact(amount, this.unit.toSeconds(1)); return Moment.of( Math.addExact(context.getPosixTime(), secs), context.getNanosecond(), POSIX ); } else { // MILLIS, MICROS, NANOS long nanos = Math.multiplyExact(amount, this.unit.toNanos(1)); long sum = Math.addExact(context.getNanosecond(), nanos); int nano = (int) Math.floorMod(sum, MRD); long second = Math.floorDiv(sum, MRD); return Moment.of( Math.addExact(context.getPosixTime(), second), nano, POSIX ); } }
new Moment( result.getNanosecond(), result.getPosixTime() + 1);