APIdia Launch Partner
Top Description Constructors Methods
javax.swing.text

public Class DateFormatter

extends InternationalFormatter
Class Inheritance
Known Direct Subclasses
javax.swing.JSpinner.DateEditorFormatter
Annotations
@SuppressWarnings:serial
Imports
java.awt.event.*, java.text.*, java.util.*, javax.swing.*, javax.swing.text.*

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 JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Since
1.4
See Also
java.text.DateFormat

Constructor Summary

AccessConstructor and Description
public
DateFormatter()

This is shorthand for new DateFormatter(DateFormat.getDateInstance()).

public
DateFormatter(DateFormat
Format used to dictate legal values
format
)

Returns a DateFormatter configured with the specified Format instance.

Method Summary

Modifier and TypeMethod and Description
pack-priv Object
adjustValue(Object value, Map<?, ?> attributes, Object key, int direction)

Overrides javax.swing.text.InternationalFormatter.adjustValue.

Adjusts the Date if FieldPosition identifies a known calendar field.

pack-priv Object
getAdjustField(int start, Map<?, ?> attributes)

Overrides javax.swing.text.InternationalFormatter.getAdjustField.

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.

pack-priv boolean
getSupportsIncrement()

Overrides javax.swing.text.InternationalFormatter.getSupportsIncrement.

Returns true, as DateFormatterFilter will support incrementing/decrementing of the value.

public void
setFormat(DateFormat
DateFormat instance used for converting from/to Strings
format
)

Sets the format that dictates the legal values that can be edited and displayed.

Inherited from javax.swing.text.InternationalFormatter:
canIncrementcanReplaceclonegetActionsgetAttributesgetAttributeStartgetBufferedChargetFieldsgetFormatgetIteratorgetLiteralgetLiteralCountTogetMaximumgetMinimumgetReplaceHolderinstallisLiteralisLiteralisNavigatableisValidMaskisValidValuereplacereplaceresetValueselectFieldsetFormatsetMaximumsetMinimumstringToValuestringToValueupdateMaskupdateMaskIfNecessaryupdateValuevalueToString

Constructor Detail

DateFormatterback to summary
public DateFormatter()

This is shorthand for new DateFormatter(DateFormat.getDateInstance()).

DateFormatterback to summary
public DateFormatter(DateFormat format)

Returns a DateFormatter configured with the specified Format instance.

Parameters
format:DateFormat

Format used to dictate legal values

Method Detail

adjustValueback to summary
pack-priv Object adjustValue(Object value, Map<?, ?> attributes, Object key, int direction) throws BadLocationException, ParseException

Overrides javax.swing.text.InternationalFormatter.adjustValue.

Adjusts the Date if FieldPosition identifies a known calendar field.

getAdjustFieldback to summary
pack-priv Object getAdjustField(int start, Map<?, ?> attributes)

Overrides javax.swing.text.InternationalFormatter.getAdjustField.

Returns the field that will be adjusted by adjustValue.

getCalendarback to summary
private Calendar getCalendar()

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

getSupportsIncrementback to summary
pack-priv boolean getSupportsIncrement()

Overrides javax.swing.text.InternationalFormatter.getSupportsIncrement.

Returns true, as DateFormatterFilter will support incrementing/decrementing of the value.

setFormatback to summary
public void setFormat(DateFormat format)

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

DateFormat instance used for converting from/to Strings