Class DurationFormat

    • Constructor Detail

      • DurationFormat

        @Deprecated
        protected DurationFormat()
        Deprecated.
        This API is ICU internal only.
        Subclass interface
      • DurationFormat

        @Deprecated
        protected DurationFormat​(ULocale locale)
        Deprecated.
        This API is ICU internal only.
        Subclass interface
    • Method Detail

      • getInstance

        @Deprecated
        public static DurationFormat getInstance​(ULocale locale)
        Deprecated.
        ICU 56
        Construct a duration format for the specified locale
      • format

        @Deprecated
        public abstract StringBuffer format​(Object object,
                                            StringBuffer toAppend,
                                            FieldPosition pos)
        Deprecated.
        ICU 56
        Format an arbitrary object. Defaults to a call to formatDurationFromNow() for either Long or Date objects.
        Specified by:
        format in class Format
        Parameters:
        object - the object to format. Should be either a Long, Date, or javax.xml.datatype.Duration object.
        toAppend - the buffer to append to
        pos - the field position, may contain additional error messages.
        Returns:
        the toAppend buffer
      • parseObject

        @Deprecated
        public Object parseObject​(String source,
                                  ParsePosition pos)
        Deprecated.
        ICU 56
        DurationFormat cannot parse, by default. This method will throw an UnsupportedOperationException.
        Specified by:
        parseObject in class Format
        Parameters:
        source - the string to parse.
        pos - input/output parameter, specifies the start index in string from where to start parsing. If parsing is successful, it is updated with the index following the parsed text; on error, the index is unchanged and the error index is set to the index where the error occurred.
        Returns:
        the object resulting from the parse or null if there is an error.
      • formatDurationFromNowTo

        @Deprecated
        public abstract String formatDurationFromNowTo​(Date targetDate)
        Deprecated.
        ICU 56
        Formats the duration between now and a target date.

        This is a convenience method that calls formatDurationFrom(long, long) using now as the reference date, and the difference between now and targetDate.getTime() as the duration.

        Parameters:
        targetDate - the ending date
        Returns:
        the formatted time
      • formatDurationFromNow

        @Deprecated
        public abstract String formatDurationFromNow​(long duration)
        Deprecated.
        ICU 56
        Formats a duration expressed in milliseconds.

        This is a convenience method that calls formatDurationFrom using the current system time as the reference date.

        Parameters:
        duration - the duration in milliseconds
        Returns:
        the formatted time
      • formatDurationFrom

        @Deprecated
        public abstract String formatDurationFrom​(long duration,
                                                  long referenceDate)
        Deprecated.
        ICU 56
        Formats a duration expressed in milliseconds from a reference date.

        The reference date allows formatters to use actual durations of variable-length periods (like months) if they wish.

        The duration is expressed as the number of milliseconds in the past (negative values) or future (positive values) with respect to a reference date (expressed as milliseconds in epoch).

        Parameters:
        duration - the duration in milliseconds
        referenceDate - the date from which to compute the duration
        Returns:
        the formatted time