2
******************************************************************************
3
* Copyright (C) 2007, International Business Machines Corporation and *
4
* others. All Rights Reserved. *
5
******************************************************************************
8
package com.ibm.icu.impl.duration;
10
import java.util.Date;
11
import java.util.TimeZone;
14
* Formatter for durations in milliseconds.
16
public interface DurationFormatter {
19
* Formats the duration between now and a target date.
21
* This is a convenience method that calls
22
* formatDurationFrom(long, long) using now
23
* as the reference date, and the difference between now and
24
* <code>targetDate.getTime()</code> as the duration.
26
* @param targetDate the ending date
27
* @return the formatted time
29
String formatDurationFromNowTo(Date targetDate);
32
* Formats a duration expressed in milliseconds.
34
* This is a convenience method that calls formatDurationFrom
35
* using the current system time as the reference date.
37
* @param duration the duration in milliseconds
38
* @param tz the time zone
39
* @return the formatted time
41
String formatDurationFromNow(long duration);
44
* Formats a duration expressed in milliseconds from a reference date.
46
* The reference date allows formatters to use actual durations of
47
* variable-length periods (like months) if they wish.
49
* The duration is expressed as the number of milliseconds in the
50
* past (negative values) or future (positive values) with respect
51
* to a reference date (expressed as milliseconds in epoch).
53
* @param duration the duration in milliseconds
54
* @param referenceDate the date from which to compute the duration
55
* @return the formatted time
57
String formatDurationFrom(long duration, long referenceDate);
60
* Returns a new DurationFormatter that's the same as this one
61
* but formats for a new locale.
63
* @param localeName the name of the new locale
64
* @return a new formatter for the given locale
66
DurationFormatter withLocale(String localeName);
69
* Returns a new DurationFormatter that's the same as this one but
70
* uses a different time zone.
72
* @param tz the time zone in which to compute durations.
73
* @return a new formatter for the given locale
75
DurationFormatter withTimeZone(TimeZone tz);