Package com.ibm.icu.text
Class DateTimePatternGenerator.FormatParser
java.lang.Object
com.ibm.icu.text.DateTimePatternGenerator.FormatParser
- Enclosing class:
DateTimePatternGenerator
Deprecated.
This API is ICU internal only.
This class provides mechanisms for parsing a SimpleDateFormat pattern
or generating a new pattern, while handling the quoting. It represents
the result of the parse as a list of items, where each item is either a
literal string or a variable field. When parsing It can be used to find
out which variable fields are in a date format, and in what order, such
as for presentation in a UI as separate text entry fields. It can also be
used to construct new SimpleDateFormats.
Example:
public boolean containsZone(String pattern) { for (Iterator it = formatParser.set(pattern).getItems().iterator(); it.hasNext();) { Object item = it.next(); if (item instanceof VariableField) { VariableField variableField = (VariableField) item; if (variableField.getType() == DateTimePatternGenerator.ZONE) { return true; } } } return false; }
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetItems()
Deprecated.This API is ICU internal only.boolean
Deprecated.This API is ICU internal only.quoteLiteral
(String string) Deprecated.This API is ICU internal only.Deprecated.This API is ICU internal only.Deprecated.This API is ICU internal only.toString()
Deprecated.This API is ICU internal only.toString
(int start, int limit) Deprecated.This API is ICU internal only.
-
Constructor Details
-
FormatParser
Deprecated.This API is ICU internal only.Construct an empty date format parser, to which strings and variables can be added with set(...).
-
-
Method Details
-
set
Deprecated.This API is ICU internal only.Parses the string into a list of items.- Parameters:
string
- The string to parse.- Returns:
- this, for chaining
-
set
Deprecated.This API is ICU internal only.Parses the string into a list of items, taking into account all of the quoting that may be going on.- Parameters:
string
- The string to parse.strict
- If true, then only allows exactly those lengths specified by CLDR for variables. For example, "hh:mm aa" would throw an exception.- Returns:
- this, for chaining
-
getItems
Deprecated.This API is ICU internal only.Returns modifiable list which is a mixture of Strings and VariableFields, in the order found during parsing. The strings represent literals, and have all quoting removed. Thus the string "dd 'de' MM" will parse into three items:VariableField: dd String: " de " VariableField: MM
The list is modifiable, so you can add any strings or variables to it, or remove any items.- Returns:
- modifiable list of items.
-
toString
Deprecated.This API is ICU internal only.Provide display form of formatted input. Each literal string is quoted if necessary.. That is, if the input was "hh':'mm", the result would be "hh:mm", since the ":" doesn't need quoting. See quoteLiteral(). -
toString
Deprecated.This API is ICU internal only.Provide display form of a segment of the parsed input. Each literal string is minimally quoted. That is, if the input was "hh':'mm", the result would be "hh:mm", since the ":" doesn't need quoting. See quoteLiteral().- Parameters:
start
- item to start fromlimit
- last item +1- Returns:
- printable output string
-
hasDateAndTimeFields
Deprecated.This API is ICU internal only.Returns true if it has a mixture of date and time variable fields: that is, at least one date variable and at least one time variable.- Returns:
- true or false
-
quoteLiteral
Deprecated.This API is ICU internal only.Each literal string is quoted as needed. That is, the ' quote marks will only be added if needed. The exact pattern of quoting is not guaranteed, thus " de la " could be quoted as " 'de la' " or as " 'de' 'la' ".- Parameters:
string
- The string to check.- Returns:
- string with quoted literals
-