Package org.jdesktop.swingx.calendar
Class DatePickerFormatter
java.lang.Object
javax.swing.JFormattedTextField.AbstractFormatter
org.jdesktop.swingx.calendar.DatePickerFormatter
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DatePickerFormatter.DatePickerFormatterUIResource
Default formatter for the JXDatePicker component.
It can handle a variety of date formats.
- Author:
- Joshua Outwater
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Same as DatePickerFormatter, but tagged as UIResource. -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a formatter with the localized format patterns defined in the swingx.properties.DatePickerFormatter
(DateFormat[] formats) Instantiates a formatter with the given date formats.DatePickerFormatter
(DateFormat[] formats, Locale locale) Instantiates a formatter with the given formats and locale.DatePickerFormatter
(Locale locale) Instantiates a formatter with default date formats in the given locale. -
Method Summary
Modifier and TypeMethodDescriptionprotected DateFormat[]
createDefaultFormats
(Locale locale) Creates and returns the localized default formats.Returns an array of the formats used by this formatter.stringToValue
(String text) valueToString
(Object value) Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter
clone, getActions, getDocumentFilter, getFormattedTextField, getNavigationFilter, install, invalidEdit, setEditValid, uninstall
-
Constructor Details
-
DatePickerFormatter
public DatePickerFormatter()Instantiates a formatter with the localized format patterns defined in the swingx.properties. These formats are localizable and fields may be re-arranged, such as swapping the month and day fields. The keys for localizing these fields are:- JXDatePicker.longFormat
- JXDatePicker.mediumFormat
- JXDatePicker.shortFormat
-
DatePickerFormatter
Instantiates a formatter with the given date formats. If the array is null, default formats are created from the localized patterns in swingx.properties. If empty?- Parameters:
formats
- the array of formats to use. May be null to use defaults or empty to do nothing (?), but must not contain null formats.
-
DatePickerFormatter
Instantiates a formatter with default date formats in the given locale. The default formats are created from the localized patterns in swingx.properties.- Parameters:
locale
- the Locale the use for the default formats.
-
DatePickerFormatter
Instantiates a formatter with the given formats and locale. PENDING JW: makes no sense as a public constructor because the locale is ignored if the formats are null. So has same public behaviour as the constructor with formats only ...- Parameters:
formats
- DateFormat arraylocale
- Locale
-
-
Method Details
-
getFormats
Returns an array of the formats used by this formatter.- Returns:
- the formats used by this formatter, guaranteed to be not null.
-
stringToValue
- Specified by:
stringToValue
in classJFormattedTextField.AbstractFormatter
- Throws:
ParseException
-
valueToString
- Specified by:
valueToString
in classJFormattedTextField.AbstractFormatter
- Throws:
ParseException
-
createDefaultFormats
Creates and returns the localized default formats. First tries to add formats created using the patterns stored in the UIManager. If there are no patterns, use the DateFormat's instance with style DateFormat.SHORT.- Parameters:
locale
- Locale- Returns:
- the localized default formats.
-