Class DateFormatter
- All Implemented Interfaces:
Serializable, Cloneable
public class DateFormatter extends InternationalFormatter
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 XMLEncoder.
- Since:
- 1.4
- See Also:
Constructor Summary
| Constructor | Description |
|---|---|
DateFormatter() |
This is shorthand for new DateFormatter(DateFormat.getDateInstance()). |
DateFormatter |
Returns a DateFormatter configured with the specified Format instance. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
void |
setFormat |
Sets the format that dictates the legal values that can be edited and displayed. |
Methods declared in class InternationalFormatter
clone, getActions, getFields, getFormat, getMaximum, getMinimum, install, setFormat, setMaximum, setMinimum, stringToValue, valueToString | Modifier and Type | Method | Description |
|---|---|---|
Object |
clone() |
Creates a copy of the DefaultFormatter. |
protected Action[] |
getActions() |
If getSupportsIncrement returns true, this returns two Actions suitable for incrementing/decrementing the value. |
Format.Field[] |
getFields |
Returns the Format.Field constants associated with the text at offset. |
Format |
getFormat() |
Returns the format that dictates the legal values that can be edited and displayed. |
Comparable |
getMaximum() |
Returns the maximum permissible value. |
Comparable |
getMinimum() |
Returns the minimum permissible value. |
void |
install |
Installs the DefaultFormatter onto a particular JFormattedTextField. |
void |
setFormat |
Sets the format that dictates the legal values that can be edited and displayed. |
void |
setMaximum |
Sets the maximum permissible value. |
void |
setMinimum |
Sets the minimum permissible value. |
Object |
stringToValue |
Returns the Object representation of the String text. |
String |
valueToString |
Returns a String representation of the Object value. |
Methods declared in class DefaultFormatter
getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getNavigationFilter, getOverwriteMode, getValueClass, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClass | Modifier and Type | Method | Description |
|---|---|---|
boolean |
getAllowsInvalid() |
Returns whether or not the value being edited is allowed to be invalid for a length of time. |
boolean |
getCommitsOnValidEdit() |
Returns when edits are published back to the JFormattedTextField. |
protected DocumentFilter |
getDocumentFilter() |
Returns the DocumentFilter used to restrict the characters that can be input into the JFormattedTextField. |
protected NavigationFilter |
getNavigationFilter() |
Returns the NavigationFilter used to restrict where the cursor can be placed. |
boolean |
getOverwriteMode() |
Returns the behavior when inserting characters. |
Class |
getValueClass() |
Returns that class that is used to create new Objects. |
void |
setAllowsInvalid |
Sets whether or not the value being edited is allowed to be invalid for a length of time (that is, stringToValue throws a ParseException). |
void |
setCommitsOnValidEdit |
Sets when edits are published back to the JFormattedTextField. |
void |
setOverwriteMode |
Configures the behavior when inserting characters. |
void |
setValueClass |
Sets that class that is used to create new Objects. |
Methods declared in class JFormattedTextField.AbstractFormatter
getFormattedTextField, invalidEdit, setEditValid, uninstall | Modifier and Type | Method | Description |
|---|---|---|
protected JFormattedTextField |
getFormattedTextField() |
Returns the current JFormattedTextField the AbstractFormatter is installed on. |
protected void |
invalidEdit() |
This should be invoked when the user types an invalid character. |
protected void |
setEditValid |
Invoke this to update the editValid property of the JFormattedTextField. |
void |
uninstall() |
Uninstalls any state the AbstractFormatter may have installed on the JFormattedTextField. |
Methods declared in class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
protected void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization is deprecated and subject to removal in a future release. |
final Class |
getClass() |
Returns the runtime class of this Object. |
int |
hashCode() |
Returns a hash code value for this object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
String |
toString() |
Returns a string representation of the object. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Constructor Details
DateFormatter
public DateFormatter()
new DateFormatter(DateFormat.getDateInstance()).DateFormatter
public DateFormatter(DateFormat format)
Format instance.- Parameters:
-
format- Format used to dictate legal values
Method Details
setFormat
public void setFormat(DateFormat format)
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
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.