Package com.ibm.icu.text
Class TimeUnitFormat
java.lang.Object
java.text.Format
com.ibm.icu.text.UFormat
com.ibm.icu.text.MeasureFormat
com.ibm.icu.text.TimeUnitFormat
- All Implemented Interfaces:
Serializable
,Cloneable
Deprecated.
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) { }
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Deprecated.Nested classes/interfaces inherited from class com.ibm.icu.text.MeasureFormat
MeasureFormat.FormatWidth, MeasureFormat.MeasureProxy, MeasureFormat.NumberFormatterCacheEntry, MeasureFormat.NumericFormatters
Nested classes/interfaces inherited from class com.ibm.icu.text.UFormat
UFormat.SpanField
Nested classes/interfaces inherited from class java.text.Format
Format.Field
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Deprecated.ICU 53 seeMeasureFormat.FormatWidth
private static final String
Deprecated.private static final String
Deprecated.private static final String
Deprecated.private static final String
Deprecated.private static final String
Deprecated.private static final String
Deprecated.private static final String
Deprecated.private NumberFormat
Deprecated.static final int
Deprecated.ICU 53 seeMeasureFormat.FormatWidth
private boolean
Deprecated.private ULocale
Deprecated.private PluralRules
Deprecated.private static final long
Deprecated.private int
Deprecated.Deprecated.private static final int
Deprecated.Fields inherited from class com.ibm.icu.text.MeasureFormat
NUMBER_FORMATTER_CURRENCY, NUMBER_FORMATTER_INTEGER, NUMBER_FORMATTER_STANDARD
-
Constructor Summary
ConstructorsModifierConstructorDescriptionDeprecated.ICU 53 useMeasureFormat
instead.TimeUnitFormat
(ULocale locale) Deprecated.ICU 53 useMeasureFormat
instead.TimeUnitFormat
(ULocale locale, int style) Deprecated.ICU 53 useMeasureFormat
instead.private
TimeUnitFormat
(ULocale locale, int style, NumberFormat numberFormat) Deprecated.TimeUnitFormat
(Locale locale) Deprecated.ICU 53 useMeasureFormat
instead.TimeUnitFormat
(Locale locale, int style) Deprecated.ICU 53 useMeasureFormat
instead. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Deprecated.ICU 53 seeMeasureFormat
Deprecated.ICU 53 seeMeasureFormat
.(package private) NumberFormat
Deprecated.Get a copy of the number format without cloning.(package private) LocalizedNumberFormatter
Deprecated.parseObject
(String source, ParsePosition pos) Deprecated.ICU 53 seeMeasureFormat
.private Object
Deprecated.private void
searchInTree
(String resourceKey, int styl, TimeUnit timeUnit, String srcPluralCount, String searchPluralCount, Map<String, Object[]> countToPatterns) Deprecated.Deprecated.ICU 53 seeMeasureFormat
.Deprecated.ICU 53 seeMeasureFormat
.setNumberFormat
(NumberFormat format) Deprecated.ICU 53 seeMeasureFormat
.private void
setup()
Deprecated.private void
setup
(String resourceKey, Map<TimeUnit, Map<String, Object[]>> timeUnitToCountToPatterns, int style, Set<String> pluralKeywords) Deprecated.private Object
Deprecated.Methods inherited from class com.ibm.icu.text.MeasureFormat
clearCache, equals, format, formatMeasurePerUnit, formatMeasures, formatMeasures, getCurrencyFormat, getCurrencyFormat, getCurrencyFormat, getInstance, getInstance, getInstance, getInstance, getLocale, getRangeFormat, getUnitDisplayName, getWidth, hashCode, toCurrencyProxy, toTimeUnitProxy, withLocale, withNumberFormat
Methods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
-
Field Details
-
FULL_NAME
Deprecated.ICU 53 seeMeasureFormat.FormatWidth
Constant for full name style format. For example, the full name for "hour" in English is "hour" or "hours".- See Also:
-
ABBREVIATED_NAME
Deprecated.ICU 53 seeMeasureFormat.FormatWidth
Constant for abbreviated name style format. For example, the abbreviated name for "hour" in English is "hr" or "hrs".- See Also:
-
TOTAL_STYLES
private static final int TOTAL_STYLESDeprecated.- See Also:
-
serialVersionUID
private static final long serialVersionUIDDeprecated.- See Also:
-
format
Deprecated. -
locale
Deprecated. -
style
private int styleDeprecated. -
timeUnitToCountToPatterns
Deprecated. -
pluralRules
Deprecated. -
isReady
private transient boolean isReadyDeprecated. -
DEFAULT_PATTERN_FOR_SECOND
Deprecated.- See Also:
-
DEFAULT_PATTERN_FOR_MINUTE
Deprecated.- See Also:
-
DEFAULT_PATTERN_FOR_HOUR
Deprecated.- See Also:
-
DEFAULT_PATTERN_FOR_DAY
Deprecated.- See Also:
-
DEFAULT_PATTERN_FOR_WEEK
Deprecated.- See Also:
-
DEFAULT_PATTERN_FOR_MONTH
Deprecated.- See Also:
-
DEFAULT_PATTERN_FOR_YEAR
Deprecated.- See Also:
-
-
Constructor Details
-
TimeUnitFormat
Deprecated.ICU 53 useMeasureFormat
instead.Create empty format using full name style, for example, "hours". Use setLocale and/or setFormat to modify. -
TimeUnitFormat
Deprecated.ICU 53 useMeasureFormat
instead.Create TimeUnitFormat given a ULocale, and using full name style.- Parameters:
locale
- locale of this time unit formatter.
-
TimeUnitFormat
Deprecated.ICU 53 useMeasureFormat
instead.Create TimeUnitFormat given a Locale, and using full name style.- Parameters:
locale
- locale of this time unit formatter.
-
TimeUnitFormat
Deprecated.ICU 53 useMeasureFormat
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:
IllegalArgumentException
- if the style is not FULL_NAME or ABBREVIATED_NAME style.
-
TimeUnitFormat
Deprecated. -
TimeUnitFormat
Deprecated.ICU 53 useMeasureFormat
instead.Create TimeUnitFormat given a Locale and a formatting style.
-
-
Method Details
-
setLocale
Deprecated.ICU 53 seeMeasureFormat
.Set the locale used for formatting or parsing.- Parameters:
locale
- locale of this time unit formatter.- Returns:
- this, for chaining.
-
setLocale
Deprecated.ICU 53 seeMeasureFormat
.Set the locale used for formatting or parsing.- Parameters:
locale
- locale of this time unit formatter.- Returns:
- this, for chaining.
-
setNumberFormat
Deprecated.ICU 53 seeMeasureFormat
.Set the format used for formatting or parsing. Passing null is equivalent to passingNumberFormat.getNumberInstance(ULocale)
.- Parameters:
format
- the number formatter.- Returns:
- this, for chaining.
-
getNumberFormat
Deprecated.ICU 53 seeMeasureFormat
.Get a copy of the number format.- Overrides:
getNumberFormat
in classMeasureFormat
-
getNumberFormatInternal
NumberFormat getNumberFormatInternal()Deprecated.Description copied from class:MeasureFormat
Get a copy of the number format without cloning. Internal method.- Overrides:
getNumberFormatInternal
in classMeasureFormat
-
getNumberFormatter
LocalizedNumberFormatter getNumberFormatter()Deprecated.- Overrides:
getNumberFormatter
in classMeasureFormat
-
parseObject
Deprecated.ICU 53 seeMeasureFormat
.Parse a TimeUnitAmount.- Overrides:
parseObject
in classMeasureFormat
- See Also:
-
setup
private void setup()Deprecated. -
setup
private void setup(String resourceKey, Map<TimeUnit, Map<String, Object[]>> timeUnitToCountToPatterns, int style, Set<String> pluralKeywords) Deprecated. -
searchInTree
private void searchInTree(String resourceKey, int styl, TimeUnit timeUnit, String srcPluralCount, String searchPluralCount, Map<String, Object[]> countToPatterns) Deprecated. -
clone
Deprecated.ICU 53 seeMeasureFormat
-
writeReplace
Deprecated.- Throws:
ObjectStreamException
-
readResolve
Deprecated.- Throws:
ObjectStreamException
-
MeasureFormat
instead.