com.jgoodies.common.format
Class EmptyDateFormat

java.lang.Object
  extended by java.text.Format
      extended by java.text.DateFormat
          extended by com.jgoodies.common.format.AbstractWrappedDateFormat
              extended by com.jgoodies.common.format.EmptyDateFormat
All Implemented Interfaces:
Serializable, Cloneable

public final class EmptyDateFormat
extends AbstractWrappedDateFormat

Wraps a given DateFormat and adds behavior to convert to/fro the empty string. Therefore it holds an empty value that i mapped to/from the empty string. The #format resul of the empty value is the empty string, and the #parsenull but you can construct a EmptyDateFormat with a given Date.

Examples:

Version:
$Revision: 1.4 $
Author:
Karsten Lentzsch
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.DateFormat
DateFormat.Field
 
Field Summary
 
Fields inherited from class com.jgoodies.common.format.AbstractWrappedDateFormat
delegate
 
Fields inherited from class java.text.DateFormat
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD
 
Constructor Summary
EmptyDateFormat(DateFormat delegate)
          Constructs an EmptyFormat that wraps the given mandatory forma to convert null to the empty string and vice versa.
EmptyDateFormat(DateFormat delegate, Date emptyValue)
          Constructs an EmptyFormat that wraps the given mandatory forma to convert the given emptyValue to the empty strin and vice versa.
 
Method Summary
 StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos)
           
 Date parse(String source, ParsePosition pos)
           
 
Methods inherited from class com.jgoodies.common.format.AbstractWrappedDateFormat
formatToCharacterIterator, getCalendar, getNumberFormat, getTimeZone, isLenient, setCalendar, setLenient, setNumberFormat, setTimeZone
 
Methods inherited from class java.text.DateFormat
clone, equals, format, format, getAvailableLocales, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getTimeInstance, getTimeInstance, getTimeInstance, hashCode, parse, parseObject
 
Methods inherited from class java.text.Format
format, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmptyDateFormat

public EmptyDateFormat(DateFormat delegate)
Constructs an EmptyFormat that wraps the given mandatory forma to convert null to the empty string and vice versa.

Parameters:
delegate - the format that handles the standard cases
Throws:
NullPointerException - if delegate is null

EmptyDateFormat

public EmptyDateFormat(DateFormat delegate,
                       Date emptyValue)
Constructs an EmptyFormat that wraps the given mandatory forma to convert the given emptyValue to the empty strin and vice versa.

Parameters:
delegate - the format that handles non-null values
emptyValue - the representation of the empty string
Throws:
NullPointerException - if delegate is null
Method Detail

format

public StringBuffer format(Date date,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
Specified by:
format in class AbstractWrappedDateFormat

parse

public Date parse(String source,
                  ParsePosition pos)
Specified by:
parse in class AbstractWrappedDateFormat


Copyright © 2009-2013 JGoodies Software GmbH. All Rights Reserved.