Package com.jgoodies.common.format
Class AbstractWrappedDateFormat
- java.lang.Object
-
- java.text.Format
-
- java.text.DateFormat
-
- com.jgoodies.common.format.AbstractWrappedDateFormat
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
EmptyDateFormat
public abstract class AbstractWrappedDateFormat extends java.text.DateFormatReduces the effort required to write custom DateFormat implementations that retain the ability to iterate through Dates with the arrow keys in formatted text fields (using an appropriate DateFormatter). This class wraps a givenDateFormatand delegates most of its behavior to the delegate, except for the abstract methodsformat(Date, StringBuffer, FieldPosition)andparse(String, ParsePosition)that can be overridden by a subclass. For example the subclass EmptyDateFormat wraps a DateFormat but it parses the empty String and returnsnullwhere the predefined Java DateFormats throw an exception.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.text.DateFormatdelegateRefers to the wrapped Format that is used to forward#formatand#parseObject.-
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
Constructors Constructor Description AbstractWrappedDateFormat(java.text.DateFormat delegate)Constructs an AbstractWrappedDateFormat that wraps the given mandatory format.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.StringBufferformat(java.util.Date date, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)java.text.AttributedCharacterIteratorformatToCharacterIterator(java.lang.Object obj)java.util.CalendargetCalendar()java.text.NumberFormatgetNumberFormat()java.util.TimeZonegetTimeZone()booleanisLenient()abstract java.util.Dateparse(java.lang.String source, java.text.ParsePosition pos)voidsetCalendar(java.util.Calendar newCalendar)voidsetLenient(boolean lenient)voidsetNumberFormat(java.text.NumberFormat newNumberFormat)voidsetTimeZone(java.util.TimeZone zone)-
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
-
-
-
-
Constructor Detail
-
AbstractWrappedDateFormat
public AbstractWrappedDateFormat(java.text.DateFormat delegate)
Constructs an AbstractWrappedDateFormat that wraps the given mandatory format.- Parameters:
delegate- the format that handles the standard cases- Throws:
java.lang.NullPointerException- ifdelegateisnull
-
-
Method Detail
-
format
public abstract java.lang.StringBuffer format(java.util.Date date, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)- Specified by:
formatin classjava.text.DateFormat
-
parse
public abstract java.util.Date parse(java.lang.String source, java.text.ParsePosition pos)- Specified by:
parsein classjava.text.DateFormat
-
getCalendar
public java.util.Calendar getCalendar()
- Overrides:
getCalendarin classjava.text.DateFormat
-
setCalendar
public void setCalendar(java.util.Calendar newCalendar)
- Overrides:
setCalendarin classjava.text.DateFormat
-
getNumberFormat
public java.text.NumberFormat getNumberFormat()
- Overrides:
getNumberFormatin classjava.text.DateFormat
-
setNumberFormat
public void setNumberFormat(java.text.NumberFormat newNumberFormat)
- Overrides:
setNumberFormatin classjava.text.DateFormat
-
getTimeZone
public java.util.TimeZone getTimeZone()
- Overrides:
getTimeZonein classjava.text.DateFormat
-
setTimeZone
public void setTimeZone(java.util.TimeZone zone)
- Overrides:
setTimeZonein classjava.text.DateFormat
-
isLenient
public boolean isLenient()
- Overrides:
isLenientin classjava.text.DateFormat
-
setLenient
public void setLenient(boolean lenient)
- Overrides:
setLenientin classjava.text.DateFormat
-
formatToCharacterIterator
public java.text.AttributedCharacterIterator formatToCharacterIterator(java.lang.Object obj)
- Overrides:
formatToCharacterIteratorin classjava.text.Format
-
-