Class TimeUnitFormat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    @Deprecated
    public class TimeUnitFormat
    extends MeasureFormat
    Deprecated.
    ICU 53 use MeasureFormat instead.
    Format or parse a TimeUnitAmount, using plural rules for the units where available.

    Code Sample:

       // create a time unit instance.
       // only SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, and YEAR are supported
       TimeUnit timeUnit = TimeUnit.SECOND;
       // create time unit amount instance - a combination of Number and time unit
       TimeUnitAmount source = new TimeUnitAmount(2, timeUnit);
       // create time unit format instance
       TimeUnitFormat format = new TimeUnitFormat();
       // set the locale of time unit format
       format.setLocale(new ULocale("en"));
       // format a time unit amount
       String formatted = format.format(source);
       System.out.println(formatted);
       try {
           // parse a string into time unit amount
           TimeUnitAmount result = (TimeUnitAmount) format.parseObject(formatted);
           // result should equal to source
       } catch (ParseException e) {
       }
     

    Author:
    markdavis
    See Also:
    TimeUnitAmount, MeasureFormat, Serialized Form
    • Field Detail

      • FULL_NAME

        @Deprecated
        public static final int FULL_NAME
        Deprecated.
        Constant for full name style format. For example, the full name for "hour" in English is "hour" or "hours".
        See Also:
        Constant Field Values
      • ABBREVIATED_NAME

        @Deprecated
        public static final int ABBREVIATED_NAME
        Deprecated.
        Constant for abbreviated name style format. For example, the abbreviated name for "hour" in English is "hr" or "hrs".
        See Also:
        Constant Field Values
    • Constructor Detail

      • TimeUnitFormat

        @Deprecated
        public TimeUnitFormat()
        Deprecated.
        ICU 53 use MeasureFormat instead.
        Create empty format using full name style, for example, "hours". Use setLocale and/or setFormat to modify.
      • TimeUnitFormat

        @Deprecated
        public TimeUnitFormat​(ULocale locale)
        Deprecated.
        ICU 53 use MeasureFormat instead.
        Create TimeUnitFormat given a ULocale, and using full name style.
        Parameters:
        locale - locale of this time unit formatter.
      • TimeUnitFormat

        @Deprecated
        public TimeUnitFormat​(java.util.Locale locale)
        Deprecated.
        ICU 53 use MeasureFormat instead.
        Create TimeUnitFormat given a Locale, and using full name style.
        Parameters:
        locale - locale of this time unit formatter.
      • TimeUnitFormat

        @Deprecated
        public TimeUnitFormat​(ULocale locale,
                              int style)
        Deprecated.
        ICU 53 use MeasureFormat instead.
        Create TimeUnitFormat given a ULocale and a formatting style.
        Parameters:
        locale - locale of this time unit formatter.
        style - format style, either FULL_NAME or ABBREVIATED_NAME style.
        Throws:
        java.lang.IllegalArgumentException - if the style is not FULL_NAME or ABBREVIATED_NAME style.
      • TimeUnitFormat

        @Deprecated
        public TimeUnitFormat​(java.util.Locale locale,
                              int style)
        Deprecated.
        ICU 53 use MeasureFormat instead.
        Create TimeUnitFormat given a Locale and a formatting style.
    • Method Detail

      • setLocale

        @Deprecated
        public TimeUnitFormat setLocale​(ULocale locale)
        Deprecated.
        ICU 53 see MeasureFormat.
        Set the locale used for formatting or parsing.
        Parameters:
        locale - locale of this time unit formatter.
        Returns:
        this, for chaining.
      • setLocale

        @Deprecated
        public TimeUnitFormat setLocale​(java.util.Locale locale)
        Deprecated.
        ICU 53 see MeasureFormat.
        Set the locale used for formatting or parsing.
        Parameters:
        locale - locale of this time unit formatter.
        Returns:
        this, for chaining.
      • parseObject

        @Deprecated
        public TimeUnitAmount parseObject​(java.lang.String source,
                                          java.text.ParsePosition pos)
        Deprecated.
        ICU 53 see MeasureFormat.
        Parse a TimeUnitAmount.
        Overrides:
        parseObject in class MeasureFormat
        See Also:
        Format.parseObject(java.lang.String, java.text.ParsePosition)
      • clone

        @Deprecated
        public java.lang.Object clone()
        Deprecated.
        This API is ICU internal only.
        Overrides:
        clone in class java.text.Format