MeasureFormat instead.@Deprecated public class TimeUnitFormat extends MeasureFormat
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) {
}
TimeUnitAmount,
MeasureFormat,
Serialized FormMeasureFormat.FormatWidthFormat.Field| Modifier and Type | Field and Description |
|---|---|
static int |
ABBREVIATED_NAME
Deprecated.
ICU 53 see
MeasureFormat.FormatWidth |
static int |
FULL_NAME
Deprecated.
ICU 53 see
MeasureFormat.FormatWidth |
| Constructor and Description |
|---|
TimeUnitFormat()
Deprecated.
ICU 53 use
MeasureFormat instead. |
TimeUnitFormat(Locale locale)
Deprecated.
ICU 53 use
MeasureFormat instead. |
TimeUnitFormat(Locale locale,
int style)
Deprecated.
ICU 53 use
MeasureFormat instead. |
TimeUnitFormat(ULocale locale)
Deprecated.
ICU 53 use
MeasureFormat instead. |
TimeUnitFormat(ULocale locale,
int style)
Deprecated.
ICU 53 use
MeasureFormat instead. |
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Deprecated.
This API is ICU internal only.
|
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
Deprecated.
ICU 53 see
MeasureFormat. |
StringBuilder |
formatMeasures(StringBuilder appendTo,
FieldPosition fieldPosition,
Measure... measures)
Deprecated.
This API is ICU internal only.
|
NumberFormat |
getNumberFormat()
Deprecated.
This API is ICU internal only.
|
MeasureFormat.FormatWidth |
getWidth()
Deprecated.
This API is ICU internal only.
|
TimeUnitAmount |
parseObject(String source,
ParsePosition pos)
Deprecated.
ICU 53 see
MeasureFormat. |
TimeUnitFormat |
setLocale(Locale locale)
Deprecated.
ICU 53 see
MeasureFormat. |
TimeUnitFormat |
setLocale(ULocale locale)
Deprecated.
ICU 53 see
MeasureFormat. |
TimeUnitFormat |
setNumberFormat(NumberFormat format)
Deprecated.
ICU 53 see
MeasureFormat. |
equals, formatMeasurePerUnit, formatMeasureRange, formatMeasures, getCurrencyFormat, getCurrencyFormat, getCurrencyFormat, getInstance, getInstance, getInstance, getInstance, getLocale, getRangeFormat, hashCodeformat, formatToCharacterIterator, parseObject@Deprecated public static final int FULL_NAME
MeasureFormat.FormatWidth@Deprecated public static final int ABBREVIATED_NAME
MeasureFormat.FormatWidth@Deprecated public TimeUnitFormat()
MeasureFormat instead.@Deprecated public TimeUnitFormat(ULocale locale)
MeasureFormat instead.locale - locale of this time unit formatter.@Deprecated public TimeUnitFormat(Locale locale)
MeasureFormat instead.locale - locale of this time unit formatter.@Deprecated public TimeUnitFormat(ULocale locale, int style)
MeasureFormat instead.locale - locale of this time unit formatter.style - format style, either FULL_NAME or ABBREVIATED_NAME style.IllegalArgumentException - if the style is not FULL_NAME or
ABBREVIATED_NAME style.@Deprecated public TimeUnitFormat(Locale locale, int style)
MeasureFormat instead.@Deprecated public TimeUnitFormat setLocale(ULocale locale)
MeasureFormat.locale - locale of this time unit formatter.@Deprecated public TimeUnitFormat setLocale(Locale locale)
MeasureFormat.locale - locale of this time unit formatter.@Deprecated public TimeUnitFormat setNumberFormat(NumberFormat format)
MeasureFormat.NumberFormat.getNumberInstance(ULocale).format - the number formatter.@Deprecated public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
MeasureFormat.format in class MeasureFormatobj - must be a Collection<? extends Measure>, Measure[], or Measure object.toAppendTo - Formatted string appended here.pos - Identifies a field in the formatted text.Format.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)@Deprecated public TimeUnitAmount parseObject(String source, ParsePosition pos)
MeasureFormat.parseObject in class MeasureFormatFormat.parseObject(java.lang.String, java.text.ParsePosition)@Deprecated public StringBuilder formatMeasures(StringBuilder appendTo, FieldPosition fieldPosition, Measure... measures)
MeasureFormatformatMeasures in class MeasureFormatappendTo - the formatted string appended here.fieldPosition - Identifies a field in the formatted text.measures - the measures to format.MeasureFormat.formatMeasures(Measure...)@Deprecated public MeasureFormat.FormatWidth getWidth()
MeasureFormatgetWidth in class MeasureFormat@Deprecated public NumberFormat getNumberFormat()
MeasureFormatgetNumberFormat in class MeasureFormat@Deprecated public Object clone()
Copyright (c) 2016 IBM Corporation and others.