|
||||||||||
| 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 Form| Field Summary | |
|---|---|
static java.lang.String |
KEY_TODAY
The resource bundle key used to localize 'Today'. |
static java.lang.String |
KEY_TOMORROW
The resource bundle key used to localize 'Tomorrow'. |
static java.lang.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(java.text.DateFormat format)
Constructs a RelativeDateFormatter using the given DateFormat with output shortcuts and relative input enabled. |
|
RelativeDateFormatter(java.text.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 java.util.ResourceBundle |
getDefaultResourceBundle()
Returns the ResourceBundle that is used as default unless overridden by an individual bundle. |
java.util.ResourceBundle |
getResourceBundle()
Returns the ResourceBundle used to lookup localized texts for Yesterday, Today, and Tomorrow. |
static void |
setDefaultResourceBundle(java.util.ResourceBundle newDefaultBundle)
Sets the ResourceBundle that is used as default for all RelativeDateFormatters that have no individual bundle set. |
void |
setResourceBundle(java.util.ResourceBundle newBundle)
Sets a ResourceBundle that will be used to lookup localized texts for Yesterday, Today, and Tomorrow. |
java.lang.Object |
stringToValue(java.lang.String text)
Returns the Object representation of the String text. |
java.lang.String |
valueToString(java.lang.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 java.lang.String KEY_YESTERDAY
public static final java.lang.String KEY_TODAY
public static final java.lang.String KEY_TOMORROW
| Constructor Detail |
|---|
public RelativeDateFormatter()
public RelativeDateFormatter(java.text.DateFormat format)
format - the DateFormat used to format and parse dates
public 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 invalid
public RelativeDateFormatter(java.text.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 invalid| Method Detail |
|---|
public java.lang.Object stringToValue(java.lang.String text)
throws java.text.ParseException
text.In addition to the delegate's behavior, this methods accepts signed integers interpreted as days relative to today.
stringToValue in class EmptyDateFormattertext - the String to convert
java.text.ParseException - if there is an error in the conversion
public java.lang.String valueToString(java.lang.Object value)
throws java.text.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 EmptyDateFormattervalue - The value to convert
java.text.ParseException - if there is an error in the conversionpublic static java.util.ResourceBundle getDefaultResourceBundle()
public static void setDefaultResourceBundle(java.util.ResourceBundle newDefaultBundle)
newDefaultBundle - the ResourceBundle to be used as defaultpublic final java.util.ResourceBundle getResourceBundle()
setResourceBundle(ResourceBundle),
getDefaultResourceBundle(),
setDefaultResourceBundle(ResourceBundle)public final void setResourceBundle(java.util.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 | |||||||||