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:
java.io.Serializable
,java.lang.Cloneable
@Deprecated public class TimeUnitFormat extends MeasureFormat
Deprecated.ICU 53 useMeasureFormat
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) { }
- See Also:
TimeUnitAmount
,MeasureFormat
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TimeUnitFormat.TimeUnitFormatSetupSink
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
-
-
Field Summary
Fields Modifier and Type Field Description static int
ABBREVIATED_NAME
Deprecated.ICU 53 seeMeasureFormat.FormatWidth
private static java.lang.String
DEFAULT_PATTERN_FOR_DAY
Deprecated.private static java.lang.String
DEFAULT_PATTERN_FOR_HOUR
Deprecated.private static java.lang.String
DEFAULT_PATTERN_FOR_MINUTE
Deprecated.private static java.lang.String
DEFAULT_PATTERN_FOR_MONTH
Deprecated.private static java.lang.String
DEFAULT_PATTERN_FOR_SECOND
Deprecated.private static java.lang.String
DEFAULT_PATTERN_FOR_WEEK
Deprecated.private static java.lang.String
DEFAULT_PATTERN_FOR_YEAR
Deprecated.private NumberFormat
format
Deprecated.static int
FULL_NAME
Deprecated.ICU 53 seeMeasureFormat.FormatWidth
private boolean
isReady
Deprecated.private ULocale
locale
Deprecated.private PluralRules
pluralRules
Deprecated.private static long
serialVersionUID
Deprecated.private int
style
Deprecated.private java.util.Map<TimeUnit,java.util.Map<java.lang.String,java.lang.Object[]>>
timeUnitToCountToPatterns
Deprecated.private static int
TOTAL_STYLES
Deprecated.-
Fields inherited from class com.ibm.icu.text.MeasureFormat
NUMBER_FORMATTER_CURRENCY, NUMBER_FORMATTER_INTEGER, NUMBER_FORMATTER_STANDARD
-
-
Constructor Summary
Constructors Modifier Constructor Description TimeUnitFormat()
Deprecated.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(java.util.Locale locale)
Deprecated.ICU 53 useMeasureFormat
instead.TimeUnitFormat(java.util.Locale locale, int style)
Deprecated.ICU 53 useMeasureFormat
instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Object
clone()
Deprecated.ICU 53 seeMeasureFormat
NumberFormat
getNumberFormat()
Deprecated.ICU 53 seeMeasureFormat
.(package private) NumberFormat
getNumberFormatInternal()
Deprecated.Get a copy of the number format without cloning.(package private) LocalizedNumberFormatter
getNumberFormatter()
Deprecated.TimeUnitAmount
parseObject(java.lang.String source, java.text.ParsePosition pos)
Deprecated.ICU 53 seeMeasureFormat
.private java.lang.Object
readResolve()
Deprecated.private void
searchInTree(java.lang.String resourceKey, int styl, TimeUnit timeUnit, java.lang.String srcPluralCount, java.lang.String searchPluralCount, java.util.Map<java.lang.String,java.lang.Object[]> countToPatterns)
Deprecated.TimeUnitFormat
setLocale(ULocale locale)
Deprecated.ICU 53 seeMeasureFormat
.TimeUnitFormat
setLocale(java.util.Locale locale)
Deprecated.ICU 53 seeMeasureFormat
.TimeUnitFormat
setNumberFormat(NumberFormat format)
Deprecated.ICU 53 seeMeasureFormat
.private void
setup()
Deprecated.private void
setup(java.lang.String resourceKey, java.util.Map<TimeUnit,java.util.Map<java.lang.String,java.lang.Object[]>> timeUnitToCountToPatterns, int style, java.util.Set<java.lang.String> pluralKeywords)
Deprecated.private java.lang.Object
writeReplace()
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
-
-
-
-
Field Detail
-
FULL_NAME
@Deprecated public static final int 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:
- Constant Field Values
-
ABBREVIATED_NAME
@Deprecated public static final int 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:
- Constant Field Values
-
TOTAL_STYLES
private static final int TOTAL_STYLES
Deprecated.- See Also:
- Constant Field Values
-
serialVersionUID
private static final long serialVersionUID
Deprecated.- See Also:
- Constant Field Values
-
format
private NumberFormat format
Deprecated.
-
locale
private ULocale locale
Deprecated.
-
style
private int style
Deprecated.
-
timeUnitToCountToPatterns
private transient java.util.Map<TimeUnit,java.util.Map<java.lang.String,java.lang.Object[]>> timeUnitToCountToPatterns
Deprecated.
-
pluralRules
private transient PluralRules pluralRules
Deprecated.
-
isReady
private transient boolean isReady
Deprecated.
-
DEFAULT_PATTERN_FOR_SECOND
private static final java.lang.String DEFAULT_PATTERN_FOR_SECOND
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_PATTERN_FOR_MINUTE
private static final java.lang.String DEFAULT_PATTERN_FOR_MINUTE
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_PATTERN_FOR_HOUR
private static final java.lang.String DEFAULT_PATTERN_FOR_HOUR
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_PATTERN_FOR_DAY
private static final java.lang.String DEFAULT_PATTERN_FOR_DAY
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_PATTERN_FOR_WEEK
private static final java.lang.String DEFAULT_PATTERN_FOR_WEEK
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_PATTERN_FOR_MONTH
private static final java.lang.String DEFAULT_PATTERN_FOR_MONTH
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_PATTERN_FOR_YEAR
private static final java.lang.String DEFAULT_PATTERN_FOR_YEAR
Deprecated.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TimeUnitFormat
@Deprecated public 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 public TimeUnitFormat(ULocale locale)
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 public TimeUnitFormat(java.util.Locale locale)
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 public TimeUnitFormat(ULocale locale, int style)
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:
java.lang.IllegalArgumentException
- if the style is not FULL_NAME or ABBREVIATED_NAME style.
-
TimeUnitFormat
private TimeUnitFormat(ULocale locale, int style, NumberFormat numberFormat)
Deprecated.
-
TimeUnitFormat
@Deprecated public TimeUnitFormat(java.util.Locale locale, int style)
Deprecated.ICU 53 useMeasureFormat
instead.Create TimeUnitFormat given a Locale and a formatting style.
-
-
Method Detail
-
setLocale
@Deprecated public TimeUnitFormat setLocale(ULocale locale)
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 public TimeUnitFormat setLocale(java.util.Locale locale)
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 public TimeUnitFormat setNumberFormat(NumberFormat format)
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 public NumberFormat 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 public TimeUnitAmount parseObject(java.lang.String source, java.text.ParsePosition pos)
Deprecated.ICU 53 seeMeasureFormat
.Parse a TimeUnitAmount.- Overrides:
parseObject
in classMeasureFormat
- See Also:
Format.parseObject(java.lang.String, java.text.ParsePosition)
-
setup
private void setup()
Deprecated.
-
setup
private void setup(java.lang.String resourceKey, java.util.Map<TimeUnit,java.util.Map<java.lang.String,java.lang.Object[]>> timeUnitToCountToPatterns, int style, java.util.Set<java.lang.String> pluralKeywords)
Deprecated.
-
searchInTree
private void searchInTree(java.lang.String resourceKey, int styl, TimeUnit timeUnit, java.lang.String srcPluralCount, java.lang.String searchPluralCount, java.util.Map<java.lang.String,java.lang.Object[]> countToPatterns)
Deprecated.
-
clone
@Deprecated public java.lang.Object clone()
Deprecated.ICU 53 seeMeasureFormat
- Overrides:
clone
in classjava.text.Format
-
writeReplace
private java.lang.Object writeReplace() throws java.io.ObjectStreamException
Deprecated.- Throws:
java.io.ObjectStreamException
-
readResolve
private java.lang.Object readResolve() throws java.io.ObjectStreamException
Deprecated.- Throws:
java.io.ObjectStreamException
-
-