com.jgoodies.binding.formatter
Class EmptyDateFormatter
DateFormatter
com.jgoodies.binding.formatter.EmptyDateFormatter
public class EmptyDateFormatter
extends DateFormatter
In addition to its superclass DateFormatter, this class converts
to/from the empty string. Therefore it holds an
empty value
that is the counterpart of the empty string.
The Method
#valueToString
converts the empty value to the
empty string. And
#stringToValue
converts blank strings
to the empty value. In all other cases the conversion is delegated
to its superclass.
Often the empty value is
null
. As an alternative you can map
the empty string to a given date, for example epoch (January 1, 1970).
Examples:
new EmptyDateFormatter();
new EmptyDateFormatter(new Date(0));
EmptyDateFormatter() - Constructs an EmptyDateFormatter that converts
null
to the empty string and vice versa.
|
EmptyDateFormatter(Date emptyValue) - Constructs an EmptyDateFormatter that converts the given
emptyValue to the empty string and vice versa.
|
EmptyDateFormatter(DateFormat format) - Constructs an EmptyDateFormatter configured with the specified
Format; maps
null to the empty string and vice versa.
|
EmptyDateFormatter(DateFormat format, Date emptyValue) - Constructs an EmptyDateFormatter configured with the specified
Format; maps
null to the given emptyValue
and vice versa.
|
EmptyDateFormatter
public EmptyDateFormatter()
Constructs an EmptyDateFormatter that converts null
to the empty string and vice versa.
EmptyDateFormatter
public EmptyDateFormatter(Date emptyValue)
Constructs an EmptyDateFormatter that converts the given
emptyValue
to the empty string and vice versa.
emptyValue
- the representation of the empty string
EmptyDateFormatter
public EmptyDateFormatter(DateFormat format)
Constructs an EmptyDateFormatter configured with the specified
Format; maps null
to the empty string and vice versa.
format
- Format used to dictate legal values
EmptyDateFormatter
public EmptyDateFormatter(DateFormat format,
Date emptyValue)
Constructs an EmptyDateFormatter configured with the specified
Format; maps null
to the given emptyValue
and vice versa.
format
- Format used to dictate legal valuesemptyValue
- the representation of the empty string
Object stringToValue
public @Override Object stringToValue(String text)
throws ParseException
Returns the
Object
representation of the
String
text
.
Unlike its superclass, this class converts blank strings
to the empty value.
Object
representation of text
String valueToString
public @Override String valueToString(Object value)
throws ParseException
Returns a String representation of the Object
value
.
This invokes
format
on the current
Format
.
Unlike its superclass, this class converts the empty value
to the empty string.
value
- the value to convert
- a String representation of value
Copyright © 2002-2008 JGoodies Karsten Lentzsch. All Rights Reserved.