• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GENERATED SOURCE. DO NOT MODIFY. */
2 // © 2016 and later: Unicode, Inc. and others.
3 // License & terms of use: http://www.unicode.org/copyright.html#License
4 /*
5 ******************************************************************************
6 * Copyright (C) 2007, International Business Machines Corporation and   *
7 * others. All Rights Reserved.                                               *
8 ******************************************************************************
9 */
10 
11 package ohos.global.icu.impl.duration;
12 
13 import java.util.Date;
14 import java.util.TimeZone;
15 
16 /**
17  * Formatter for durations in milliseconds.
18  * @hide exposed on OHOS
19  */
20 public interface DurationFormatter {
21 
22   /**
23    * Formats the duration between now and a target date.
24    * <p>
25    * This is a convenience method that calls
26    * formatDurationFrom(long, long) using now
27    * as the reference date, and the difference between now and
28    * <code>targetDate.getTime()</code> as the duration.
29    *
30    * @param targetDate the ending date
31    * @return the formatted time
32    */
formatDurationFromNowTo(Date targetDate)33   String formatDurationFromNowTo(Date targetDate);
34 
35   /**
36    * Formats a duration expressed in milliseconds.
37    * <p>
38    * This is a convenience method that calls formatDurationFrom
39    * using the current system time as the reference date.
40    *
41    * @param duration the duration in milliseconds
42    * @param tz the time zone
43    * @return the formatted time
44    */
formatDurationFromNow(long duration)45   String formatDurationFromNow(long duration);
46 
47   /**
48    * Formats a duration expressed in milliseconds from a reference date.
49    * <p>
50    * The reference date allows formatters to use actual durations of
51    * variable-length periods (like months) if they wish.
52    * <p>
53    * The duration is expressed as the number of milliseconds in the
54    * past (negative values) or future (positive values) with respect
55    * to a reference date (expressed as milliseconds in epoch).
56    *
57    * @param duration the duration in milliseconds
58    * @param referenceDate the date from which to compute the duration
59    * @return the formatted time
60    */
formatDurationFrom(long duration, long referenceDate)61   String formatDurationFrom(long duration, long referenceDate);
62 
63   /**
64    * Returns a new DurationFormatter that's the same as this one
65    * but formats for a new locale.
66    *
67    * @param localeName the name of the new locale
68    * @return a new formatter for the given locale
69    */
withLocale(String localeName)70   DurationFormatter withLocale(String localeName);
71 
72   /**
73    * Returns a new DurationFormatter that's the same as this one but
74    * uses a different time zone.
75    *
76    * @param tz the time zone in which to compute durations.
77    * @return a new formatter for the given locale
78    */
withTimeZone(TimeZone tz)79   DurationFormatter withTimeZone(TimeZone tz);
80 }
81