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 useMeasureFormatinstead.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.ibm.icu.text.MeasureFormat
MeasureFormat.FormatWidth
-
-
Field Summary
Fields Modifier and Type Field Description static intABBREVIATED_NAMEDeprecated.ICU 53 seeMeasureFormat.FormatWidthstatic intFULL_NAMEDeprecated.ICU 53 seeMeasureFormat.FormatWidth
-
Constructor Summary
Constructors Constructor Description TimeUnitFormat()Deprecated.ICU 53 useMeasureFormatinstead.TimeUnitFormat(ULocale locale)Deprecated.ICU 53 useMeasureFormatinstead.TimeUnitFormat(ULocale locale, int style)Deprecated.ICU 53 useMeasureFormatinstead.TimeUnitFormat(java.util.Locale locale)Deprecated.ICU 53 useMeasureFormatinstead.TimeUnitFormat(java.util.Locale locale, int style)Deprecated.ICU 53 useMeasureFormatinstead.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Objectclone()Deprecated.This API is ICU internal only.java.lang.StringBufferformat(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)Deprecated.ICU 53 seeMeasureFormat.java.lang.StringBuilderformatMeasures(java.lang.StringBuilder appendTo, java.text.FieldPosition fieldPosition, Measure... measures)Deprecated.This API is ICU internal only.NumberFormatgetNumberFormat()Deprecated.This API is ICU internal only.MeasureFormat.FormatWidthgetWidth()Deprecated.This API is ICU internal only.TimeUnitAmountparseObject(java.lang.String source, java.text.ParsePosition pos)Deprecated.ICU 53 seeMeasureFormat.TimeUnitFormatsetLocale(ULocale locale)Deprecated.ICU 53 seeMeasureFormat.TimeUnitFormatsetLocale(java.util.Locale locale)Deprecated.ICU 53 seeMeasureFormat.TimeUnitFormatsetNumberFormat(NumberFormat format)Deprecated.ICU 53 seeMeasureFormat.-
Methods inherited from class com.ibm.icu.text.MeasureFormat
equals, formatMeasurePerUnit, formatMeasureRange, formatMeasures, getCurrencyFormat, getCurrencyFormat, getCurrencyFormat, getInstance, getInstance, getInstance, getInstance, getLocale, getPluralFormatter, getRangeFormat, getUnitDisplayName, hashCode
-
-
-
-
Field Detail
-
FULL_NAME
@Deprecated public static final int FULL_NAME
Deprecated.ICU 53 seeMeasureFormat.FormatWidthConstant 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.FormatWidthConstant 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 useMeasureFormatinstead.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 useMeasureFormatinstead.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 useMeasureFormatinstead.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 useMeasureFormatinstead.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 useMeasureFormatinstead.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.
-
format
@Deprecated public java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)Deprecated.ICU 53 seeMeasureFormat.Format a TimeUnitAmount.- Overrides:
formatin classMeasureFormat- Parameters:
obj- must be a Collection<? extends Measure>, Measure[], or Measure object.toAppendTo- Formatted string appended here.pos- Identifies a field in the formatted text.- See Also:
Format.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
-
parseObject
@Deprecated public TimeUnitAmount parseObject(java.lang.String source, java.text.ParsePosition pos)
Deprecated.ICU 53 seeMeasureFormat.Parse a TimeUnitAmount.- Overrides:
parseObjectin classMeasureFormat- See Also:
Format.parseObject(java.lang.String, java.text.ParsePosition)
-
formatMeasures
@Deprecated public java.lang.StringBuilder formatMeasures(java.lang.StringBuilder appendTo, java.text.FieldPosition fieldPosition, Measure... measures)Deprecated.This API is ICU internal only.Description copied from class:MeasureFormatFormats a sequence of measures. If the fieldPosition argument identifies a NumberFormat field, then its indices are set to the beginning and end of the first such field encountered. MeasureFormat itself does not supply any fields.- Overrides:
formatMeasuresin classMeasureFormat- Parameters:
appendTo- the formatted string appended here.fieldPosition- Identifies a field in the formatted text.measures- the measures to format.- Returns:
- appendTo.
- See Also:
MeasureFormat.formatMeasures(Measure...)
-
getWidth
@Deprecated public MeasureFormat.FormatWidth getWidth()
Deprecated.This API is ICU internal only.Description copied from class:MeasureFormatGet the format width this instance is using.- Overrides:
getWidthin classMeasureFormat
-
getNumberFormat
@Deprecated public NumberFormat getNumberFormat()
Deprecated.This API is ICU internal only.Description copied from class:MeasureFormatGet a copy of the number format.- Overrides:
getNumberFormatin classMeasureFormat
-
clone
@Deprecated public java.lang.Object clone()
Deprecated.This API is ICU internal only.- Overrides:
clonein classjava.text.Format
-
-