public class TimeFormatter extends DateTimeFormatter
Date
values in a
FormattedText
, restricting the edit and display to the time part.
Supports a subset of time patterns defined in SimpleDateFormat
for input.
See DateTimeFormatter
for a full description of patterns, given
that only patterns chars related to time are allowed.
new TimeFormatter("HH:mm")
- 15:45:11 will edit
and display as "15:45".new TimeFormatter("hh:mm a, "h:m a")
- 05:05 AM will edit
as "05:05 AM" and display as "5:5 AM".cachedPatterns, calendar, fieldCount, fields, flistener, inputCache, inputMask, klistener, locale, modifyFilter, sdfDisplay, yearStart
EMPTY, ignore, SPACE, text
Constructor and Description |
---|
TimeFormatter()
Constructs a new instance with all defaults :
edit mask in SHORT time format for the default locale
display mask identical to the edit mask
default locale
|
TimeFormatter(java.util.Locale loc)
Constructs a new instance with default edit and display masks for the given
locale.
|
TimeFormatter(java.lang.String editPattern)
Constructs a new instance with the given edit mask.
|
TimeFormatter(java.lang.String editPattern,
java.util.Locale loc)
Constructs a new instance with the given edit mask and locale.
|
TimeFormatter(java.lang.String editPattern,
java.lang.String displayPattern)
Constructs a new instance with the given edit and display masks.
|
TimeFormatter(java.lang.String editPattern,
java.lang.String displayPattern,
java.util.Locale loc)
Constructs a new instance with the given masks and locale.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDefaultEditPattern(java.util.Locale loc)
Returns the default edit pattern for the given
Locale . |
protected void |
isValidCharPattern(char c)
Checks if a given char is valid for the edit pattern.
|
detach, getDisplayString, getEditString, getLocale, getValue, getValueType, isEmpty, isValid, setLocale, setText, setTimeZone, setValue, verifyText
beep, setIgnore, updateText, updateText
public TimeFormatter()
public TimeFormatter(java.util.Locale loc)
loc
- localepublic TimeFormatter(java.lang.String editPattern)
editPattern
- edit maskpublic TimeFormatter(java.lang.String editPattern, java.util.Locale loc)
editPattern
- edit maskloc
- localepublic TimeFormatter(java.lang.String editPattern, java.lang.String displayPattern)
editPattern
- edit maskdisplayPattern
- display maskpublic TimeFormatter(java.lang.String editPattern, java.lang.String displayPattern, java.util.Locale loc)
editPattern
- edit maskdisplayPattern
- display maskloc
- localepublic java.lang.String getDefaultEditPattern(java.util.Locale loc)
Locale
.
A DateFormat
object is instantiated with SHORT format for
both the time part for the given locale. The corresponding pattern
string is then retrieved by calling the toPattern
.
Default patterns are stored in a cache with ISO3 language and country codes as key. So they are computed only once by locale.
getDefaultEditPattern
in class DateTimeFormatter
loc
- localeprotected void isValidCharPattern(char c)
isValidCharPattern
in class DateTimeFormatter
c
- pattern charjava.lang.IllegalArgumentException
- if not validDateTimeFormatter.isValidCharPattern(char)