com.ibm.icu.text
public class DateTimePatternGenerator extends Object implements Freezable, Cloneable
The main method people will use is getBestPattern(String skeleton), since normally this class is pre-built with data from a particular locale. However, generators can be built directly from other data as well.
Issue: may be useful to also have a function that returns the list of fields in a pattern, in order, since we have that internally. That would be useful for getting the UI order of field elements.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Nested Class Summary | |
---|---|
static class | DateTimePatternGenerator.FormatParser
Class providing date formatting |
static class | DateTimePatternGenerator.PatternInfo
PatternInfo supplies output parameters for add(...). |
static class | DateTimePatternGenerator.VariableField
Utility class for FormatParser. |
Field Summary | |
---|---|
static int | DAY |
static int | DAYPERIOD |
static int | DAY_OF_WEEK_IN_MONTH |
static int | DAY_OF_YEAR |
static int | ERA |
static int | FRACTIONAL_SECOND |
static int | HOUR |
static int | MINUTE |
static int | MONTH |
static int | QUARTER |
static int | SECOND |
static int | TYPE_LIMIT |
static int | WEEKDAY |
static int | WEEK_OF_MONTH |
static int | WEEK_OF_YEAR |
static int | YEAR |
static int | ZONE |
Constructor Summary | |
---|---|
protected | DateTimePatternGenerator()
Only for use by subclasses |
Method Summary | |
---|---|
DateTimePatternGenerator | add(String pattern, boolean override, DateTimePatternGenerator.PatternInfo returnInfo)
Adds a pattern to the generator. |
Object | clone()
Boilerplate |
Object | cloneAsThawed()
Boilerplate for Freezable |
Object | freeze()
Boilerplate for Freezable |
String | getAppendItemFormats(int field)
Getter corresponding to setAppendItemFormats. |
String | getAppendItemNames(int field)
Getter corresponding to setAppendItemNames. |
String | getBaseSkeleton(String pattern)
Utility to return a unique base skeleton from a given pattern. |
Set | getBaseSkeletons(Set result)
Return a list of all the base skeletons (in canonical form) from this class |
String | getBestPattern(String skeleton)
Return the best pattern matching the input skeleton. |
String | getDateTimeFormat()
Getter corresponding to setDateTimeFormat.
|
String | getDecimal()
Getter corresponding to setDecimal. |
String | getFields(String pattern)
internal routine |
static DateTimePatternGenerator | getInstance()
Construct a flexible generator according to data for a given locale. |
static DateTimePatternGenerator | getInstance(ULocale uLocale)
Construct a flexible generator according to data for a given locale. |
Collection | getRedundants(Collection output)
Redundant patterns are those which if removed, make no difference in the
resulting getBestPattern values. |
String | getSkeleton(String pattern)
Utility to return a unique skeleton from a given pattern. |
Map | getSkeletons(Map result)
Return a list of all the skeletons (in canonical form) from this class,
and the patterns that they map to.
|
boolean | isFrozen()
Boilerplate for Freezable |
static boolean | isSingleField(String skeleton)
Determines whether a skeleton contains a single field
|
static DateTimePatternGenerator | newInstance()
Create empty generator, to be constructed with add(...) etc. |
String | replaceFieldTypes(String pattern, String skeleton)
Adjusts the field types (width and subtype) of a pattern to match what is
in a skeleton. |
void | setAppendItemFormats(int field, String value)
An AppendItem format is a pattern used to append a field if there is no
good match. |
void | setAppendItemNames(int field, String value)
Sets the names of fields, eg "era" in English for ERA. |
void | setDateTimeFormat(String dateTimeFormat)
The date time format is a message format pattern used to compose date and
time patterns. |
void | setDecimal(String decimal)
The decimal value is used in formatting fractions of seconds. |
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Note that single-field patterns (like "MMM") are automatically added, and don't need to be added explicitly!
Parameters: override when existing values are to be overridden use true, otherwise use false.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: field
Returns: append pattern for field
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: field
Returns: name for field
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: pattern Input pattern, such as "dd/MMM"
Returns: skeleton, such as "MMMdd"
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: skeleton The skeleton is a pattern containing only the variable fields. For example, "MMMdd" and "mmhh" are skeletons.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Returns: pattern
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Returns: string corresponding to the decimal point
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Deprecated:
internal routineParameters: pattern
Returns: field value
UNKNOWN:
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: uLocale
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Deprecated:
Redundant patterns are those which if removed, make no difference in the resulting getBestPattern values. This method returns a list of them, to help check the consistency of the patterns used to build this generator.Parameters: output stores the redundant patterns that are removed. To get these in internal order, supply a LinkedHashSet. If null, a collection is allocated.
Returns: the collection with added elements.
UNKNOWN:
Parameters: pattern Input pattern, such as "dd/MMM"
Returns: skeleton, such as "MMMdd"
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: result
an output Map in which to place the mapping from skeleton to
pattern. If you want to see the internal order being used,
supply a LinkedHashMap. If the input value is null, then a
LinkedHashMap is allocated.
Issue: an alternate API would be to just return a list of
the skeletons, and then have a separate routine to get from
skeleton to pattern.
Returns: the input Map containing the values.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Deprecated:
Determines whether a skeleton contains a single fieldParameters: skeleton
Returns: true or not
UNKNOWN:
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: pattern input pattern skeleton
Returns: pattern adjusted to match the skeleton fields widths and subtypes.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
There are actually three available variables: {0} is the pattern so far, {1} is the element we are adding, and {2} is the name of the element.
This reflects the way that the CLDR data is organized.
Parameters: field such as ERA value pattern, such as "{0}, {1}"
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
This reflects the way that the CLDR data is organized.
Parameters: field value
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
This is used when the input skeleton contains both date and time fields, but there is not a close match among the added patterns. For example, suppose that this object was created by adding "dd-MMM" and "hh:mm", and its datetimeFormat is the default "{0} {1}". Then if the input skeleton is "MMMdhmm", there is not an exact match, so the input skeleton is broken up into two components "MMMd" and "hmm". There are close matches for those two skeletons, so the result is put together with this pattern, resulting in "d-MMM h:mm".
Parameters: dateTimeFormat message format pattern, here {0} will be replaced by the date pattern and {1} will be replaced by the time pattern.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: decimal
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.