public final class TLcdDurationFormat
extends java.text.Format
Format
which handles ILcdISO19103Measure
instances
which have a unit of measure
with measure type
TLcdISO19103MeasureTypeCodeExtension.DURATION
Days {DaysTextSeparator} Hours {HoursTextSeparator} Minutes {MinutesTextSeparator} Seconds {SecondsTextSeparator} TrimOptionwhere:
TL
: To trim the left part of the expression, removing the starting items equal to 0, if presentTR
: To trim the right part of the expression, removing the ending items equal to 0, if presentTLR
: to trim both left and right
TLcdDurationFormat format = new TLcdDurationFormat(TLcdDurationFormat.NON_ZERO_ONLY);
ILcdISO19103Measure measure = (ILcdISO19103Measure) format.parseObject("3h 0m 10s");
ILcdISO19103Measure measure = new TLcdISO19103Measure(3.4, TLcdUnitOfMeasureFactory.DURATION_SECONDS);
String formatted = format.format(measure);
Pattern | Result |
---|---|
d {d} h {hour :hours } s.ff {second:seconds} |
3hours 10.40seconds |
s.f {s} |
10,810.4s |
m.FFF {minute:minutes} |
180.173minutes |
h {heures} |
3heures |
dd {d } HHH {h} |
003h |
DD {d : days} HH {h :hours } MM {m :minutes} |
00d 03hours 00m |
DD {d : days} HH {h :hours } MM {m :minutes} TL |
03hours 00m |
DD {d : days} HH {h :hours } MM {m :minutes} TR |
00d 03hours |
DD {d : days} HH {h :hours } MM {m :minutes} TLR |
03hours |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LONG_SEPARATORS_PATTERN
Same as
MINIMUM_PATTERN but with longer separators, with a distinction between the singular form and the plural one.d {day :days } h {hour :hours } m {minute :minutes } s.f {second :seconds } |
static java.lang.String |
MINIMUM_PATTERN
This pattern only displays the items with a value above 0.
d {d } h {h } m {m } s.f {s} |
static java.lang.String |
NON_ZERO_ONLY
This pattern displays every element and trims the expression left and right the values equal to 0.
DD {d } HH {h } MM {m } SS.f {s} TLR |
Constructor and Description |
---|
TLcdDurationFormat()
Creates a new
TLcdDurationFormat that will use a default pattern and Locale. |
TLcdDurationFormat(java.lang.String aPattern)
Creates a new
TLcdDurationFormat that will use the specified pattern and a default Locale. |
TLcdDurationFormat(java.lang.String aPattern,
java.util.Locale aLocale)
Creates a new
TLcdDurationFormat that will use the specified pattern and the specified locale. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object aO) |
java.lang.StringBuffer |
format(java.lang.Object aObject,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos) |
java.lang.String |
getPattern()
Returns the pattern used to format Strings into
ILcdISO19103Measure instances. |
int |
hashCode() |
java.lang.Object |
parseObject(java.lang.String aSource,
java.text.ParsePosition pos) |
java.lang.String |
toString() |
public static final java.lang.String MINIMUM_PATTERN
d {d } h {h } m {m } s.f {s}
public static final java.lang.String LONG_SEPARATORS_PATTERN
MINIMUM_PATTERN
but with longer separators, with a distinction between the singular form and the plural one.d {day :days } h {hour :hours } m {minute :minutes } s.f {second :seconds }
public static final java.lang.String NON_ZERO_ONLY
DD {d } HH {h } MM {m } SS.f {s} TLR
public TLcdDurationFormat()
TLcdDurationFormat
that will use a default pattern and Locale.public TLcdDurationFormat(java.lang.String aPattern)
TLcdDurationFormat
that will use the specified pattern and a default Locale.aPattern
- is the string representing the formatting pattern, as defined in the class documentation.java.lang.IllegalArgumentException
- When aPattern
is not a valid pattern.java.lang.NullPointerException
- when aPattern
is null.public TLcdDurationFormat(java.lang.String aPattern, java.util.Locale aLocale)
TLcdDurationFormat
that will use the specified pattern and the specified locale.aPattern
- is the string representing the formatting pattern, as defined in the class documentation.aLocale
- the Locale
to be used to parse and format.java.lang.IllegalArgumentException
- When aPattern
is not a valid pattern.java.lang.NullPointerException
- when aPattern
or aLocale
is null.public java.lang.String getPattern()
ILcdISO19103Measure
instances.public java.lang.StringBuffer format(java.lang.Object aObject, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
format
in class java.text.Format
public java.lang.Object parseObject(java.lang.String aSource, java.text.ParsePosition pos)
parseObject
in class java.text.Format
public boolean equals(java.lang.Object aO)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object