Home | History | Annotate | Download | only in text
      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-2015, International Business Machines Corporation and
      7  * others. All Rights Reserved.
      8  *******************************************************************************
      9  */
     10 package android.icu.text;
     11 
     12 import java.text.FieldPosition;
     13 import java.text.ParsePosition;
     14 import java.util.Date;
     15 
     16 import android.icu.impl.duration.BasicDurationFormat;
     17 import android.icu.util.ULocale;
     18 
     19 /**
     20  * This <b>deprecated</b> class implements a formatter over a duration in time
     21  * such as "2 days from now" or "3 hours ago".
     22  *
     23  * <p>Use MeasureFormat to format periods like "5 days, 3 hours";
     24  * use RelativeDateTimeFormatter to format relative dates like "5 days ago".
     25  *
     26  * @see MeasureFormat
     27  * @see RelativeDateTimeFormatter
     28  * @deprecated ICU 56 Use MeasureFormat or RelativeDateTimeFormatter instead.
     29  * @hide Only a subset of ICU is exposed in Android
     30  */
     31 @Deprecated
     32 public abstract class DurationFormat extends UFormat {
     33 
     34     private static final long serialVersionUID = -2076961954727774282L;
     35 
     36     /**
     37      * Construct a duration format for the specified locale
     38      * @deprecated ICU 56
     39      */
     40     @Deprecated
     41     public static DurationFormat getInstance(ULocale locale) {
     42         return BasicDurationFormat.getInstance(locale);
     43     }
     44 
     45 
     46     /**
     47      * Subclass interface
     48      * @deprecated This API is ICU internal only.
     49      * @hide draft / provisional / internal are hidden on Android
     50      */
     51     @Deprecated
     52     protected DurationFormat() {
     53     }
     54 
     55     /**
     56      * Subclass interface
     57      * @deprecated This API is ICU internal only.
     58      * @hide draft / provisional / internal are hidden on Android
     59      */
     60     @Deprecated
     61     protected DurationFormat(ULocale locale) {
     62         setLocale(locale,locale);
     63     }
     64 
     65     /**
     66      * Format an arbitrary object.
     67      * Defaults to a call to formatDurationFromNow() for either Long or Date objects.
     68      * @param object the object to format. Should be either a Long, Date, or javax.xml.datatype.Duration object.
     69      * @param toAppend the buffer to append to
     70      * @param pos the field position, may contain additional error messages.
     71      * @return the toAppend buffer
     72      * @deprecated ICU 56
     73      */
     74     @Deprecated
     75     @Override
     76     public abstract StringBuffer format(Object object, StringBuffer toAppend,
     77             FieldPosition pos);
     78 
     79     /**
     80      * DurationFormat cannot parse, by default. This method will throw an UnsupportedOperationException.
     81      * @deprecated ICU 56
     82      */
     83     @Override
     84     @Deprecated
     85     public Object parseObject(String source, ParsePosition pos) {
     86        throw new UnsupportedOperationException();
     87     }
     88 
     89     /**
     90      * Formats the duration between now and a target date.
     91      * <p>
     92      * This is a convenience method that calls
     93      * formatDurationFrom(long, long) using now
     94      * as the reference date, and the difference between now and
     95      * <code>targetDate.getTime()</code> as the duration.
     96      *
     97      * @param targetDate the ending date
     98      * @return the formatted time
     99      * @deprecated ICU 56
    100      */
    101     @Deprecated
    102     public abstract String formatDurationFromNowTo(Date targetDate);
    103 
    104     /**
    105      * Formats a duration expressed in milliseconds.
    106      * <p>
    107      * This is a convenience method that calls formatDurationFrom
    108      * using the current system time as the reference date.
    109      *
    110      * @param duration the duration in milliseconds
    111      * @return the formatted time
    112      * @deprecated ICU 56
    113      */
    114     @Deprecated
    115     public abstract String formatDurationFromNow(long duration);
    116 
    117     /**
    118      * Formats a duration expressed in milliseconds from a reference date.
    119      * <p>
    120      * The reference date allows formatters to use actual durations of
    121      * variable-length periods (like months) if they wish.
    122      * <p>
    123      * The duration is expressed as the number of milliseconds in the
    124      * past (negative values) or future (positive values) with respect
    125      * to a reference date (expressed as milliseconds in epoch).
    126      *
    127      * @param duration the duration in milliseconds
    128      * @param referenceDate the date from which to compute the duration
    129      * @return the formatted time
    130      * @deprecated ICU 56
    131      */
    132     @Deprecated
    133     public abstract String formatDurationFrom(long duration, long referenceDate);
    134 }
    135