System.out.println(pt.printRelative(moment, paris)); System.out.println(pt.printRelative(now, paris)); System.out.println(pt.printRelative(shortTimeAgo, paris)); System.out.println(pt.printRelative(shortTimeAgo, Timezone.of(paris), precision));
/** * <p>Formats given threeten object relative to the current time of * {@link #getReferenceClock()} as duration in at most second * precision or less. </p> * * @param zdt relative time * @return formatted output of relative time, either in past or in future * @see #printRelative(Instant, ZoneId) * @since 4.8 */ /*[deutsch] * <p>Formatiert den angegebenen Zeitpunkt in JSR-310-Schreibweise relativ zur aktuellen Zeit * der Referenzuhr {@link #getReferenceClock()} als Dauer in maximal * Sekundengenauigkeit. </p> * * @param zdt relative time * @return formatted output of relative time, either in past or in future * @see #printRelative(Instant, ZoneId) * @since 4.8 */ public String printRelative(ZonedDateTime zdt) { return this.printRelative(zdt.toInstant(), zdt.getZone()); }
/** * <p>Formats given time point relative to the current time of * {@link #getReferenceClock()} as duration in at most second * precision or less - using the system timezone. </p> * * @param moment relative time point * @return formatted output of relative time, either in past or in future * @see #printRelative(UnixTime, Timezone, TimeUnit) * @since 3.4/4.3 */ /*[deutsch] * <p>Formatiert den angegebenen Zeitpunkt relativ zur aktuellen Zeit * der Referenzuhr {@link #getReferenceClock()} als Dauer in maximal * Sekundengenauigkeit - bezüglich der Systemzeitzone. </p> * * @param moment relative time point * @return formatted output of relative time, either in past or in future * @see #printRelative(UnixTime, Timezone, TimeUnit) * @since 3.4/4.3 */ public String printRelativeInStdTimezone(UnixTime moment) { return this.printRelative(moment, Timezone.ofSystem(), TimeUnit.SECONDS); }
/** * <p>Formats given time point relative to the current time of * {@link #getReferenceClock()} as duration in at most second * precision or less. </p> * * @param moment relative time point * @param tzid time zone id for translating to a local duration * @return formatted output of relative time, either in past or in future * @see #printRelative(UnixTime, Timezone, TimeUnit) * @since 1.2 */ /*[deutsch] * <p>Formatiert den angegebenen Zeitpunkt relativ zur aktuellen Zeit * der Referenzuhr {@link #getReferenceClock()} als Dauer in maximal * Sekundengenauigkeit. </p> * * @param moment relative time point * @param tzid time zone id for translating to a local duration * @return formatted output of relative time, either in past or in future * @see #printRelative(UnixTime, Timezone, TimeUnit) * @since 1.2 */ public String printRelative( UnixTime moment, String tzid ) { return this.printRelative(moment, Timezone.of(tzid), TimeUnit.SECONDS); }
) { return this.printRelative(moment, Timezone.of(tzid), TimeUnit.SECONDS);
/** * <p>Formats given time point relative to the current time of * {@link #getReferenceClock()} as duration in at most second * precision or less. </p> * * @param instant relative time point * @param zoneId time zone id for translating to a local duration * @return formatted output of relative time, either in past or in future * @see #printRelative(UnixTime, Timezone, TimeUnit) * @since 4.8 */ /*[deutsch] * <p>Formatiert den angegebenen Zeitpunkt relativ zur aktuellen Zeit * der Referenzuhr {@link #getReferenceClock()} als Dauer in maximal * Sekundengenauigkeit. </p> * * @param instant relative time point * @param zoneId time zone id for translating to a local duration * @return formatted output of relative time, either in past or in future * @see #printRelative(UnixTime, Timezone, TimeUnit) * @since 4.8 */ public String printRelative( Instant instant, ZoneId zoneId ) { return this.printRelative(Moment.from(instant), Timezone.of(zoneId.getId()), TimeUnit.SECONDS); }