org.jdesktop.swingx.calendar
Class DatePickerFormatter

java.lang.Object
  extended by javax.swing.JFormattedTextField.AbstractFormatter
      extended by org.jdesktop.swingx.calendar.DatePickerFormatter
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
DatePickerFormatter.DatePickerFormatterUIResource

public class DatePickerFormatter
extends javax.swing.JFormattedTextField.AbstractFormatter

Default formatter for the JXDatePicker component. It can handle a variety of date formats.

Author:
Joshua Outwater
See Also:
Serialized Form

Nested Class Summary
static class DatePickerFormatter.DatePickerFormatterUIResource
          Same as DatePickerFormatter, but tagged as UIResource.
 
Constructor Summary
DatePickerFormatter()
          Instantiates a formatter with the localized format patterns defined in the swingx.properties.
DatePickerFormatter(java.text.DateFormat[] formats)
          Instantiates a formatter with the given date formats.
DatePickerFormatter(java.text.DateFormat[] formats, java.util.Locale locale)
          Instantiates a formatter with the given formats and locale.
DatePickerFormatter(java.util.Locale locale)
          Instantiates a formatter with default date formats in the given locale.
 
Method Summary
 java.text.DateFormat[] getFormats()
          Returns an array of the formats used by this formatter.
 java.lang.Object stringToValue(java.lang.String text)
          
 java.lang.String valueToString(java.lang.Object value)
          
 
Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter
install, uninstall
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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:


DatePickerFormatter

public DatePickerFormatter(java.text.DateFormat[] formats)
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

public DatePickerFormatter(java.util.Locale locale)
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

public DatePickerFormatter(java.text.DateFormat[] formats,
                           java.util.Locale locale)
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 -
locale -
Method Detail

getFormats

public java.text.DateFormat[] getFormats()
Returns an array of the formats used by this formatter.

Returns:
the formats used by this formatter, guaranteed to be not null.

stringToValue

public java.lang.Object stringToValue(java.lang.String text)
                               throws java.text.ParseException

Specified by:
stringToValue in class javax.swing.JFormattedTextField.AbstractFormatter
Throws:
java.text.ParseException

valueToString

public java.lang.String valueToString(java.lang.Object value)
                               throws java.text.ParseException

Specified by:
valueToString in class javax.swing.JFormattedTextField.AbstractFormatter
Throws:
java.text.ParseException