|
|||||||||
| Home >> All >> com >> jgoodies >> validation >> tutorial >> formatted >> [ format overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.jgoodies.validation.tutorial.formatted.format
Class RelativeDateFormat

java.lang.Objectjava.text.Format
java.text.DateFormat
com.jgoodies.validation.tutorial.formatted.format.RelativeDateFormat
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public final class RelativeDateFormat
- extends java.text.DateFormat
A Format that provides special handling for output
shortcuts and relative input.
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.
This class is intended for demonstration purposes only. It is superceded by
the com.jgoodies.validation.formatter.RelativeDateFormatter.
- Version:
- $Revision: 1.5 $
| Nested Class Summary |
| Nested classes inherited from class java.text.DateFormat |
java.text.DateFormat.Field |
| Field Summary | |
private boolean |
allowRelativeInput
|
private java.text.DateFormat |
delegate
|
private static java.text.NumberFormat |
INTEGER_FORMAT
|
static java.lang.String |
KEY_TODAY
|
static java.lang.String |
KEY_TOMORROW
|
static java.lang.String |
KEY_YESTERDAY
|
private java.util.ResourceBundle |
resourceBundle
Refers to an optional ResourceBundle that is used to localize the texts for the output shortcuts: Yesterday, Today, Tomorrow. |
private boolean |
useOutputShortcuts
|
private static java.lang.String |
VALUE_TODAY
|
private static java.lang.String |
VALUE_TOMORROW
|
private static java.lang.String |
VALUE_YESTERDAY
|
| Constructor Summary | |
RelativeDateFormat()
Constructs a wrapped format that provides special handling for output shortcuts and relative input. |
|
RelativeDateFormat(java.text.DateFormat delegate,
boolean useOutputShortcuts,
boolean allowRelativeInput)
Constructs a wrapped format that provides special handling for output shortcuts and relative input. |
|
| Method Summary | |
private static java.text.Format |
createDateFormat(int style,
boolean useOutputShortcuts,
boolean allowRelativeInput)
Creates and returns a Format that converts
Dates to Strings and vice versa. |
java.lang.StringBuffer |
format(java.util.Date date,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition fieldPosition)
Formats a Date into a date/time string. |
static java.text.Format |
getDefaultDisplayDateFormat()
Creates and answers the default Format that is used
to edit instances of java.util.Date in the UI:
It converts null to empty Strings,
uses the short DateFormat,
uses shortcuts for output and
does not accepts relative input. |
static java.text.Format |
getDefaultEditDateFormat()
Creates and answers the default Format that is used
to edit instances of java.util.Date in the UI:
It converts null to empty Strings,
uses the short DateFormat,
uses shortcuts for output and
accepts relative input. |
static java.text.Format |
getDefaultPrintDateFormat()
Creates and answers the default Format that is used
to edit instances of java.util.Date in the UI:
It converts null to empty Strings,
uses the short DateFormat,
does not uses shortcuts for output and
does not accepts relative input. |
java.util.ResourceBundle |
getResourceBundle()
|
private java.lang.String |
getString(java.lang.String key,
java.lang.String defaultText)
Retrieves and returns a String for the given key from the
a resource bundle. |
java.util.Date |
parse(java.lang.String source,
java.text.ParsePosition pos)
Parse a date/time string according to the given parse position. |
void |
setResourceBundle(java.util.ResourceBundle newBundle)
|
| Methods inherited from class java.text.DateFormat |
clone, equals, format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, hashCode, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone |
| Methods inherited from class java.text.Format |
format, formatToCharacterIterator, parseObject |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
KEY_YESTERDAY
public static final java.lang.String KEY_YESTERDAY
- See Also:
- Constant Field Values
KEY_TODAY
public static final java.lang.String KEY_TODAY
- See Also:
- Constant Field Values
KEY_TOMORROW
public static final java.lang.String KEY_TOMORROW
- See Also:
- Constant Field Values
VALUE_YESTERDAY
private static final java.lang.String VALUE_YESTERDAY
- See Also:
- Constant Field Values
VALUE_TODAY
private static final java.lang.String VALUE_TODAY
- See Also:
- Constant Field Values
VALUE_TOMORROW
private static final java.lang.String VALUE_TOMORROW
- See Also:
- Constant Field Values
INTEGER_FORMAT
private static final java.text.NumberFormat INTEGER_FORMAT
delegate
private final java.text.DateFormat delegate
useOutputShortcuts
private final boolean useOutputShortcuts
allowRelativeInput
private final boolean allowRelativeInput
resourceBundle
private java.util.ResourceBundle resourceBundle
- Refers to an optional ResourceBundle that is used to localize
the texts for the output shortcuts: Yesterday, Today, Tomorrow.
| Constructor Detail |
RelativeDateFormat
public RelativeDateFormat()
- Constructs a wrapped format that provides special handling
for output shortcuts and relative input.
RelativeDateFormat
public RelativeDateFormat(java.text.DateFormat delegate, boolean useOutputShortcuts, boolean allowRelativeInput)
- Constructs a wrapped format that provides special handling
for output shortcuts and relative input.
| Method Detail |
getDefaultEditDateFormat
public static java.text.Format getDefaultEditDateFormat()
- Creates and answers the default
Formatthat is used to edit instances of java.util.Date in the UI: It convertsnullto empty Strings, uses the shortDateFormat, uses shortcuts for output and accepts relative input.
getDefaultDisplayDateFormat
public static java.text.Format getDefaultDisplayDateFormat()
- Creates and answers the default
Formatthat is used to edit instances of java.util.Date in the UI: It convertsnullto empty Strings, uses the shortDateFormat, uses shortcuts for output and does not accepts relative input.
getDefaultPrintDateFormat
public static java.text.Format getDefaultPrintDateFormat()
- Creates and answers the default
Formatthat is used to edit instances of java.util.Date in the UI: It convertsnullto empty Strings, uses the shortDateFormat, does not uses shortcuts for output and does not accepts relative input.
createDateFormat
private static java.text.Format createDateFormat(int style, boolean useOutputShortcuts, boolean allowRelativeInput)
- Creates and returns a
Formatthat converts Dates to Strings and vice versa. The format uses the specified java.text.DateFormat style and can be configured via the parameters. Also, the editable format allows to enter shortcuts forPrintable indicates that dates must always be converted using absolute numbers, where displayed dates will use shortcuts for yesterday, today and tomorrow.
format
public java.lang.StringBuffer format(java.util.Date date, java.lang.StringBuffer toAppendTo, java.text.FieldPosition fieldPosition)
- Formats a Date into a date/time string.
In addition to the delegate's behavior, this method formats
the dates for yesterday, today and tomorrow to the natural
language strings.
parse
public java.util.Date parse(java.lang.String source, java.text.ParsePosition pos)
- Parse a date/time string according to the given parse position. For
example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
that is equivalent to Date(837039928046).
By default, parsing is lenient: If the input is not in the form used by this object's format method but can still be parsed as a date, then the parse succeeds. Clients may insist on strict adherence to the format by calling setLenient(false).
In addition to the delegate's behavior, this methods accepts signed integers interpreted as days relative to today.
getResourceBundle
public java.util.ResourceBundle getResourceBundle()
setResourceBundle
public void setResourceBundle(java.util.ResourceBundle newBundle)
getString
private java.lang.String getString(java.lang.String key, java.lang.String defaultText)
- Retrieves and returns a
Stringfor the given key from the a resource bundle. This implementation refers to the bundle that is provided by the UIF'sResourceManager.
|
|||||||||
| Home >> All >> com >> jgoodies >> validation >> tutorial >> formatted >> [ format overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC