com.jgoodies.common.format

Class EmptyDateFormat

public final class EmptyDateFormat extends AbstractWrappedDateFormat

Wraps a given DateFormat and adds behavior to convert to/from the empty string. Therefore it holds an empty value that is mapped to/from the empty string. The {@code #format} result of the empty value is the empty string, and the {@code #parse} result of the empty string is the empty value. In all other cases the formatting and parsing is forwarded to the wrapped DateFormat.

Often the empty value is {@code null} but you can construct an EmptyDateFormat with a given {@code Date}.

Examples:

 new EmptyDateFormat(DateFormat.getDateInstance());
 new EmptyDateFormat(DateFormat.getDateInstance(), new Date());

 new EmptyDateFormat(DateFormat.getDateInstance(DateFormat.SHORT));
 new EmptyDateFormat(DateFormat.getDateInstance(DateFormat.SHORT), new Date());
 

Version: $Revision: 1.6 $

Author: Karsten Lentzsch

Constructor Summary
EmptyDateFormat(DateFormat delegate)
Constructs an {@code EmptyFormat} that wraps the given format to convert {@code null} to the empty string and vice versa.
EmptyDateFormat(DateFormat delegate, Date emptyValue)
Constructs an {@code EmptyFormat} that wraps the given format to convert the given {@code emptyValue} to the empty string and vice versa.

Constructor Detail

EmptyDateFormat

public EmptyDateFormat(DateFormat delegate)
Constructs an {@code EmptyFormat} that wraps the given format to convert {@code null} to the empty string and vice versa.

Parameters: delegate the format that handles the standard cases

EmptyDateFormat

public EmptyDateFormat(DateFormat delegate, Date emptyValue)
Constructs an {@code EmptyFormat} that wraps the given format to convert the given {@code emptyValue} to the empty string and vice versa.

Parameters: delegate the format that handles non-{@code null} values emptyValue the representation of the empty string

Copyright © 2009-2010 JGoodies Karsten Lentzsch. All Rights Reserved.