@SuppressWarnings("unchecked") private static Moment subtract( Moment moment, MachineTime<?> duration ) { if (duration.getScale() == TimeScale.UTC) { MachineTime<SI> mt = (MachineTime<SI>) duration; return moment.minus(mt); } else { MachineTime<TimeUnit> mt = (MachineTime<TimeUnit>) duration; return moment.minus(mt); } }
/** * <p>Subtracts given real time from this timestamp on the UTC time scale. </p> * * @param realTime real time defined in UTC time space * @return changed copy of this instance * @throws UnsupportedOperationException if either this moment or the result are before 1972 * @throws ArithmeticException in case of overflow * @since 3.23/4.19 */ /*[deutsch] * <p>Subtrahiert die angegegebene Realzeit von der UTC-Zeit dieses Zeitstempels. </p> * * @param realTime real time defined in UTC time space * @return changed copy of this instance * @throws UnsupportedOperationException if either this moment or the result are before 1972 * @throws ArithmeticException in case of overflow * @since 3.23/4.19 */ public Moment minus(RealTime<SI> realTime) { return this.minus(realTime.getSeconds(), SI.SECONDS).minus(realTime.getFraction(), SI.NANOSECONDS); }
Moment shortTimeAgo = now.minus(15, SI.SECONDS); System.out.println(pt.printRelative(shortTimeAgo, paris));