Top Description Inners Fields Constructors Methods
com.ibm.icu.text

public Class TimeUnitFormat

extends MeasureFormat
Class Inheritance
Annotations
@Deprecated
Imports
java.io.ObjectStreamException, java.text.ParseException, .ParsePosition, java.util.HashMap, .Locale, .Map, .Map.Entry, .MissingResourceException, .Set, .TreeMap, com.ibm.icu.impl.ICUData, .ICUResourceBundle, .UResource, com.ibm.icu.number.LocalizedNumberFormatter, com.ibm.icu.util.TimeUnit, .TimeUnitAmount, .ULocale, .ULocale.Category, .UResourceBundle

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
public static final int
ABBREVIATED_NAME

Constant for abbreviated name style format.

private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private NumberFormat
public static final int
FULL_NAME

Constant for full name style format.

private transient boolean
private ULocale
private transient PluralRules
private static final long
private int
private transient Map<TimeUnit, Map<String, Object[]>>
private static final int
Inherited from com.ibm.icu.text.MeasureFormat:
NUMBER_FORMATTER_CURRENCYNUMBER_FORMATTER_INTEGERNUMBER_FORMATTER_STANDARD

Constructor Summary

AccessConstructor and Description
public
TimeUnitFormat()

Deprecated ICU 53 use MeasureFormat instead.
Create empty format using full name style, for example, "hours".
public
TimeUnitFormat(ULocale
locale of this time unit formatter.
locale
)

Deprecated ICU 53 use MeasureFormat instead.
Create TimeUnitFormat given a ULocale, and using full name style.
public
TimeUnitFormat(Locale
locale of this time unit formatter.
locale
)

Deprecated ICU 53 use MeasureFormat instead.
Create TimeUnitFormat given a Locale, and using full name style.
public
TimeUnitFormat(ULocale
locale of this time unit formatter.
locale
,
int
format style, either FULL_NAME or ABBREVIATED_NAME style.
style
)

Deprecated ICU 53 use MeasureFormat instead.
Create TimeUnitFormat given a ULocale and a formatting style.
private
TimeUnitFormat(ULocale locale, int style, NumberFormat numberFormat)

public
TimeUnitFormat(Locale locale, int style)

Deprecated ICU 53 use MeasureFormat instead.
Create TimeUnitFormat given a Locale and a formatting style.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.text.Format.clone.

Deprecated ICU 53 see MeasureFormat
Creates and returns a copy of this object.
public NumberFormat
getNumberFormat()

Overrides com.ibm.icu.text.MeasureFormat.getNumberFormat.

Deprecated ICU 53 see MeasureFormat.
Get a copy of the number format.
pack-priv NumberFormat
getNumberFormatInternal()

Overrides com.ibm.icu.text.MeasureFormat.getNumberFormatInternal.

Get a copy of the number format without cloning.
pack-priv LocalizedNumberFormatter
public TimeUnitAmount
parseObject(String
A String, part of which should be parsed.
source
,
ParsePosition
A ParsePosition object with index and error index information as described above.
pos
)

Overrides com.ibm.icu.text.MeasureFormat.parseObject.

Deprecated ICU 53 see MeasureFormat.
Parse a TimeUnitAmount.
private Object
private void
searchInTree(String resourceKey, int styl, TimeUnit timeUnit, String srcPluralCount, String searchPluralCount, Map<String, Object[]> countToPatterns)

public TimeUnitFormat

Returns:

this, for chaining.
setLocale
(ULocale
locale of this time unit formatter.
locale
)

Deprecated ICU 53 see MeasureFormat.
Set the locale used for formatting or parsing.
public TimeUnitFormat

Returns:

this, for chaining.
setLocale
(Locale
locale of this time unit formatter.
locale
)

Deprecated ICU 53 see MeasureFormat.
Set the locale used for formatting or parsing.
public TimeUnitFormat

Returns:

this, for chaining.
setNumberFormat
(NumberFormat
the number formatter.
format
)

Deprecated ICU 53 see MeasureFormat.
Set the format used for formatting or parsing.
private void
private void
setup(String resourceKey, Map<TimeUnit, Map<String, Object[]>> timeUnitToCountToPatterns, int style, Set<String> pluralKeywords)

private Object
Inherited from com.ibm.icu.text.MeasureFormat:
clearCacheequalsformatformatMeasurePerUnitformatMeasuresformatMeasuresgetCurrencyFormatgetCurrencyFormatgetCurrencyFormatgetInstancegetInstancegetInstancegetInstancegetLocalegetRangeFormatgetUnitDisplayNamegetWidthhashCodetoCurrencyProxytoTimeUnitProxywithLocalewithNumberFormat

Field Detail

ABBREVIATED_NAMEback to summary
public static final int ABBREVIATED_NAME

Deprecated

ICU 53 see MeasureFormat.FormatWidth

Constant for abbreviated name style format. For example, the abbreviated name for "hour" in English is "hr" or "hrs".

Annotations
@Deprecated
DEFAULT_PATTERN_FOR_DAYback to summary
private static final String DEFAULT_PATTERN_FOR_DAY
DEFAULT_PATTERN_FOR_HOURback to summary
private static final String DEFAULT_PATTERN_FOR_HOUR
DEFAULT_PATTERN_FOR_MINUTEback to summary
private static final String DEFAULT_PATTERN_FOR_MINUTE
DEFAULT_PATTERN_FOR_MONTHback to summary
private static final String DEFAULT_PATTERN_FOR_MONTH
DEFAULT_PATTERN_FOR_SECONDback to summary
private static final String DEFAULT_PATTERN_FOR_SECOND
DEFAULT_PATTERN_FOR_WEEKback to summary
private static final String DEFAULT_PATTERN_FOR_WEEK
DEFAULT_PATTERN_FOR_YEARback to summary
private static final String DEFAULT_PATTERN_FOR_YEAR
formatback to summary
private NumberFormat format
FULL_NAMEback to summary
public static final int FULL_NAME

Deprecated

ICU 53 see MeasureFormat.FormatWidth

Constant for full name style format. For example, the full name for "hour" in English is "hour" or "hours".

Annotations
@Deprecated
isReadyback to summary
private transient boolean isReady
localeback to summary
private ULocale locale
pluralRulesback to summary
private transient PluralRules pluralRules
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.ibm.icu.text.MeasureFormat.serialVersionUID.

styleback to summary
private int style
timeUnitToCountToPatternsback to summary
private transient Map<TimeUnit, Map<String, Object[]>> timeUnitToCountToPatterns
TOTAL_STYLESback to summary
private static final int TOTAL_STYLES

Constructor Detail

TimeUnitFormatback to summary
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.

Annotations
@Deprecated
TimeUnitFormatback to summary
public TimeUnitFormat(ULocale locale)

Deprecated

ICU 53 use MeasureFormat instead.

Create TimeUnitFormat given a ULocale, and using full name style.

Parameters
locale:ULocale

locale of this time unit formatter.

Annotations
@Deprecated
TimeUnitFormatback to summary
public TimeUnitFormat(Locale locale)

Deprecated

ICU 53 use MeasureFormat instead.

Create TimeUnitFormat given a Locale, and using full name style.

Parameters
locale:Locale

locale of this time unit formatter.

Annotations
@Deprecated
TimeUnitFormatback to summary
public TimeUnitFormat(ULocale locale, int style)

Deprecated

ICU 53 use MeasureFormat instead.

Create TimeUnitFormat given a ULocale and a formatting style.

Parameters
locale:ULocale

locale of this time unit formatter.

style:int

format style, either FULL_NAME or ABBREVIATED_NAME style.

Annotations
@Deprecated
Exceptions
IllegalArgumentException:
if the style is not FULL_NAME or ABBREVIATED_NAME style.
TimeUnitFormatback to summary
private TimeUnitFormat(ULocale locale, int style, NumberFormat numberFormat)
TimeUnitFormatback to summary
public TimeUnitFormat(Locale locale, int style)

Deprecated

ICU 53 use MeasureFormat instead.

Create TimeUnitFormat given a Locale and a formatting style.

Annotations
@Deprecated

Method Detail

cloneback to summary
public Object clone()

Overrides java.text.Format.clone.

Doc from java.text.Format.clone.

Deprecated

ICU 53 see MeasureFormat

Creates and returns a copy of this object.

Returns:Object

a clone of this instance.

Annotations
@Deprecated
@Override
getNumberFormatback to summary
public NumberFormat getNumberFormat()

Overrides com.ibm.icu.text.MeasureFormat.getNumberFormat.

Doc from com.ibm.icu.text.MeasureFormat.getNumberFormat.

Deprecated

ICU 53 see MeasureFormat.

Get a copy of the number format.

Annotations
@Override
@Deprecated
getNumberFormatInternalback to summary
pack-priv NumberFormat getNumberFormatInternal()

Overrides com.ibm.icu.text.MeasureFormat.getNumberFormatInternal.

Doc from com.ibm.icu.text.MeasureFormat.getNumberFormatInternal.

Get a copy of the number format without cloning. Internal method.

Annotations
@Override
getNumberFormatterback to summary
pack-priv LocalizedNumberFormatter getNumberFormatter()

Overrides com.ibm.icu.text.MeasureFormat.getNumberFormatter.

Annotations
@Override
parseObjectback to summary
public TimeUnitAmount parseObject(String source, ParsePosition pos)

Overrides com.ibm.icu.text.MeasureFormat.parseObject.

Deprecated

ICU 53 see MeasureFormat.

Parse a TimeUnitAmount.

Parameters
source:String

Doc from java.text.Format.parseObject.

A String, part of which should be parsed.

pos:ParsePosition

Doc from java.text.Format.parseObject.

A ParsePosition object with index and error index information as described above.

Returns:TimeUnitAmount

Doc from java.text.Format.parseObject.

An Object parsed from the string. In case of error, returns null.

Annotations
@Deprecated
@Override
See Also
java.text.Format#parseObject(java.lang.String, java.text.ParsePosition)
readResolveback to summary
private Object readResolve() throws ObjectStreamException
searchInTreeback to summary
private void searchInTree(String resourceKey, int styl, TimeUnit timeUnit, String srcPluralCount, String searchPluralCount, Map<String, Object[]> countToPatterns)
setLocaleback to summary
public TimeUnitFormat setLocale(ULocale locale)

Deprecated

ICU 53 see MeasureFormat.

Set the locale used for formatting or parsing.

Parameters
locale:ULocale

locale of this time unit formatter.

Returns:TimeUnitFormat

this, for chaining.

Annotations
@Deprecated
setLocaleback to summary
public TimeUnitFormat setLocale(Locale locale)

Deprecated

ICU 53 see MeasureFormat.

Set the locale used for formatting or parsing.

Parameters
locale:Locale

locale of this time unit formatter.

Returns:TimeUnitFormat

this, for chaining.

Annotations
@Deprecated
setNumberFormatback to summary
public TimeUnitFormat setNumberFormat(NumberFormat format)

Deprecated

ICU 53 see MeasureFormat.

Set the format used for formatting or parsing. Passing null is equivalent to passing NumberFormat#getNumberInstance(ULocale).

Parameters
format:NumberFormat

the number formatter.

Returns:TimeUnitFormat

this, for chaining.

Annotations
@Deprecated
setupback to summary
private void setup()
setupback to summary
private void setup(String resourceKey, Map<TimeUnit, Map<String, Object[]>> timeUnitToCountToPatterns, int style, Set<String> pluralKeywords)
writeReplaceback to summary
private Object writeReplace() throws ObjectStreamException

Hides com.ibm.icu.text.MeasureFormat.writeReplace.

com.ibm.icu.text back to summary

private final Class TimeUnitFormat.TimeUnitFormatSetupSink

extends Sink
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv ULocale
pack-priv Set<String>
pack-priv int
pack-priv Map<TimeUnit, Map<String, Object[]>>

Constructor Summary

AccessConstructor and Description
pack-priv
TimeUnitFormatSetupSink(Map<TimeUnit, Map<String, Object[]>> timeUnitToCountToPatterns, int style, Set<String> pluralKeywords, ULocale locale)

Method Summary

Modifier and TypeMethod and Description
public void
put(UResource.Key
Initially the key string of the enumeration-start resource. Empty if the enumeration starts at the top level of the bundle. Reuse for output values from Array and Table getters.
key
,
UResource.Value
Call getArray() or getTable() as appropriate. Then reuse for output values from Array and Table getters.
value
,
boolean
true if the bundle has no parent; that is, its top-level table has the nofallback attribute, or it is the root bundle of a locale tree.
noFallback
)

Implements abstract com.ibm.icu.impl.UResource.Sink.put.

Called once for each bundle (child-parent-...-root).

Field Detail

beenHereback to summary
pack-priv boolean beenHere
localeback to summary
pack-priv ULocale locale
pluralKeywordsback to summary
pack-priv Set<String> pluralKeywords
styleback to summary
pack-priv int style
timeUnitToCountToPatternsback to summary
pack-priv Map<TimeUnit, Map<String, Object[]>> timeUnitToCountToPatterns

Constructor Detail

TimeUnitFormatSetupSinkback to summary
pack-priv TimeUnitFormatSetupSink(Map<TimeUnit, Map<String, Object[]>> timeUnitToCountToPatterns, int style, Set<String> pluralKeywords, ULocale locale)

Method Detail

putback to summary
public void put(UResource.Key key, UResource.Value value, boolean noFallback)

Implements abstract com.ibm.icu.impl.UResource.Sink.put.

Doc from com.ibm.icu.impl.UResource.Sink.put.

Called once for each bundle (child-parent-...-root). The value is normally an array or table resource, and implementations of this method normally iterate over the tree of resource items stored there.

Parameters
key:UResource.Key

Initially the key string of the enumeration-start resource. Empty if the enumeration starts at the top level of the bundle. Reuse for output values from Array and Table getters.

value:UResource.Value

Call getArray() or getTable() as appropriate. Then reuse for output values from Array and Table getters.

noFallback:boolean

true if the bundle has no parent; that is, its top-level table has the nofallback attribute, or it is the root bundle of a locale tree.

Annotations
@Override