javax.swing.text
Class DateFormatter

java.lang.Object
  |
  +--javax.swing.JFormattedTextField.AbstractFormatter
        |
        +--javax.swing.text.DefaultFormatter
              |
              +--javax.swing.text.InternationalFormatter
                    |
                    +--javax.swing.text.DateFormatter
All Implemented Interfaces:
Cloneable, Serializable
Direct Known Subclasses:
javax.swing.JSpinner.DateEditorFormatter

public class DateFormatter
extends InternationalFormatter

Safe: DateFormatter is an InternationalFormatter that does its formatting by way of an instance of java.text.DateFormat.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder.

Since:
1.4
Version:
1.5 04/09/01
See Also:
java.text.DateFormat, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.text.InternationalFormatter
 
Fields inherited from class javax.swing.text.DefaultFormatter
replaceHolder
 
Fields inherited from class javax.swing.AbstractFormatter
 
Constructor Summary
DateFormatter()
          Enabled: This is shorthand for new DateFormatter(DateFormat.getDateInstance()).
DateFormatter(java.text.DateFormat format)
          Enabled: Returns a DateFormatter configured with the specified Format instance.
 
Method Summary
(package private)  Object adjustValue(Object value, Map attributes, Object key, int direction)
          Adjusts the Date if FieldPosition identifies a known calendar field.
(package private)  Object getAdjustField(int start, Map attributes)
          Returns the field that will be adjusted by adjustValue.
private  Calendar getCalendar()
          Returns the Calendar that DateFormat is associated with, or if the Format is not a DateFormat Calendar.getInstance is returned.
(package private)  boolean getSupportsIncrement()
          Returns true, as DateFormatterFilter will support incrementing/decrementing of the value.
 void setFormat(java.text.DateFormat format)
          Enabled: Sets the format that dictates the legal values that can be edited and displayed.
 
Methods inherited from class javax.swing.text.InternationalFormatter
canIncrement, canReplace, clone, getActions, getAttributes, getAttributeStart, getBufferedChar, getFields, getFormat, getIterator, getLiteral, getLiteralCountTo, getMaximum, getMinimum, getReplaceHolder, install, isLiteral, isLiteral, isNavigatable, isValidMask, isValidValue, replace, replace, resetValue, selectField, setFormat, setMaximum, setMinimum, stringToValue, stringToValue, updateMask, updateMaskIfNecessary, updateValue, valueToString
 
Methods inherited from class javax.swing.text.DefaultFormatter
commitEdit, getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getInitialVisualPosition, getNavigationFilter, getNextCursorPosition, getNextVisualPositionFrom, getOverwriteMode, getReplaceString, getValueClass, isLegalInsertText, isValidEdit, moveDot, positionCursorAtInitialLocation, repositionCursor, setAllowsInvalid, setCommitsOnValidEdit, setDot, setOverwriteMode, setValueClass, updateValue
 
Methods inherited from class javax.swing.AbstractFormatter
getFormattedTextField, invalidEdit, setEditValid, uninstall
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormatter

public DateFormatter()
Enabled: This is shorthand for new DateFormatter(DateFormat.getDateInstance()).


DateFormatter

public DateFormatter(java.text.DateFormat format)
Enabled: Returns a DateFormatter configured with the specified Format instance.

Parameters:
format - Format used to dictate legal values
Method Detail

setFormat

public void setFormat(java.text.DateFormat format)
Enabled: Sets the format that dictates the legal values that can be edited and displayed.

If you have used the nullary constructor the value of this property will be determined for the current locale by way of the Dateformat.getDateInstance() method.

Parameters:
format - DateFormat instance used for converting from/to Strings

getCalendar

private Calendar getCalendar()
Returns the Calendar that DateFormat is associated with, or if the Format is not a DateFormat Calendar.getInstance is returned.


getSupportsIncrement

boolean getSupportsIncrement()
Returns true, as DateFormatterFilter will support incrementing/decrementing of the value.

Overrides:
getSupportsIncrement in class InternationalFormatter

getAdjustField

Object getAdjustField(int start,
                      Map attributes)
Returns the field that will be adjusted by adjustValue.

Overrides:
getAdjustField in class InternationalFormatter

adjustValue

Object adjustValue(Object value,
                   Map attributes,
                   Object key,
                   int direction)
             throws BadLocationException,
                    java.text.ParseException
Adjusts the Date if FieldPosition identifies a known calendar field.

Overrides:
adjustValue in class InternationalFormatter
BadLocationException
java.text.ParseException


comments?