|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.JFormattedTextField.AbstractFormatter
javax.swing.text.DefaultFormatter
javax.swing.text.InternationalFormatter
javax.swing.text.DateFormatter
com.jgoodies.validation.formatter.EmptyDateFormatter
com.jgoodies.validation.formatter.RelativeDateFormatter
public class RelativeDateFormatter
Adds relative dates and output shortcuts to its superclass EmptyDateFormatter.
If output shortcuts are enabled, Yesterday, Today and Tomorrow are formatted using their localized human-language print strings.
If relative input is allowed, the parser accepts signed integers that encode a date relative to today; this input would otherwise be considered invalid.
ValidationUtils
,
JFormattedTextField
,
Serialized FormField Summary | |
---|---|
static String |
KEY_TODAY
The resource bundle key used to localize 'Today'. |
static String |
KEY_TOMORROW
The resource bundle key used to localize 'Tomorrow'. |
static String |
KEY_YESTERDAY
The resource bundle key used to localize 'Yesterday'. |
Constructor Summary | |
---|---|
RelativeDateFormatter()
Constructs a RelativeDateFormatter using the default DateFormat with output shortcuts and relative input enabled. |
|
RelativeDateFormatter(boolean useOutputShortcuts,
boolean allowRelativeInput)
Constructs a RelativeDateFormatter using the default DateFormat with output shortcuts and relative input configured as specified. |
|
RelativeDateFormatter(DateFormat format)
Constructs a RelativeDateFormatter using the given DateFormat with output shortcuts and relative input enabled. |
|
RelativeDateFormatter(DateFormat format,
boolean useOutputShortcuts,
boolean allowRelativeInput)
Constructs a RelativeDateFormatter using the given DateFormat with output shortcuts and relative input configured as specified. |
Method Summary | |
---|---|
static ResourceBundle |
getDefaultResourceBundle()
Returns the ResourceBundle that is used as default unless overridden by an individual bundle. |
ResourceBundle |
getResourceBundle()
Returns the ResourceBundle used to lookup localized texts for Yesterday, Today, and Tomorrow. |
static void |
setDefaultResourceBundle(ResourceBundle newDefaultBundle)
Sets the ResourceBundle that is used as default for all RelativeDateFormatters that have no individual bundle set. |
void |
setResourceBundle(ResourceBundle newBundle)
Sets a ResourceBundle that will be used to lookup localized texts for Yesterday, Today, and Tomorrow. |
Object |
stringToValue(String text)
Returns the Object representation of the String text . |
String |
valueToString(Object value)
Returns a String representation of the Object value . |
Methods inherited from class javax.swing.text.DateFormatter |
---|
setFormat |
Methods inherited from class javax.swing.text.InternationalFormatter |
---|
clone, getActions, getFields, getFormat, getMaximum, getMinimum, install, setFormat, setMaximum, setMinimum |
Methods inherited from class javax.swing.text.DefaultFormatter |
---|
getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getNavigationFilter, getOverwriteMode, getValueClass, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClass |
Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter |
---|
getFormattedTextField, invalidEdit, setEditValid, uninstall |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String KEY_YESTERDAY
public static final String KEY_TODAY
public static final String KEY_TOMORROW
Constructor Detail |
---|
public RelativeDateFormatter()
public RelativeDateFormatter(DateFormat format)
format
- the DateFormat used to format and parse datespublic RelativeDateFormatter(boolean useOutputShortcuts, boolean allowRelativeInput)
useOutputShortcuts
- true indicates that dates are formatted
with shortcuts for yesterday, today, and tomorrow, where false
always converts using absolute numbers for day, month and year.allowRelativeInput
- true indicates that the parser accepts
signed integers that encode a date relative to today; if false
such input is considered invalidpublic RelativeDateFormatter(DateFormat format, boolean useOutputShortcuts, boolean allowRelativeInput)
format
- the DateFormat used to format and parse datesuseOutputShortcuts
- true indicates that dates are formatted
with shortcuts for yesterday, today, and tomorrow, where false
always converts using absolute numbers for day, month and year.allowRelativeInput
- true indicates that the parser accepts
signed integers that encode a date relative to today; if false
such input is considered invalidMethod Detail |
---|
public Object stringToValue(String text) throws ParseException
text
.In addition to the delegate's behavior, this methods accepts signed integers interpreted as days relative to today.
stringToValue
in class EmptyDateFormatter
text
- the String to convert
ParseException
- if there is an error in the conversionpublic String valueToString(Object value) throws ParseException
value
.
This invokes format
on the current DateFormat.In addition to the superclass behavior, this method formats the dates for yesterday, today and tomorrow to the natural language strings.
valueToString
in class EmptyDateFormatter
value
- The value to convert
ParseException
- if there is an error in the conversionpublic static ResourceBundle getDefaultResourceBundle()
public static void setDefaultResourceBundle(ResourceBundle newDefaultBundle)
newDefaultBundle
- the ResourceBundle to be used as defaultpublic final ResourceBundle getResourceBundle()
setResourceBundle(ResourceBundle)
,
getDefaultResourceBundle()
,
setDefaultResourceBundle(ResourceBundle)
public final void setResourceBundle(ResourceBundle newBundle)
newBundle
- the ResourceBundle to setgetResourceBundle()
,
getDefaultResourceBundle()
,
setDefaultResourceBundle(ResourceBundle)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |