Package com.jgoodies.common.format
Class AbstractWrappedDateFormat
java.lang.Object
java.text.Format
java.text.DateFormat
com.jgoodies.common.format.AbstractWrappedDateFormat
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
EmptyDateFormat
Reduces 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 given
DateFormat and delegates most
of its behavior to the delegate, except for the abstract methods
format(Date, StringBuffer, FieldPosition) and
parse(String, ParsePosition) that can be overridden by
a subclass. For example the subclass EmptyDateFormat wraps a DateFormat
but it parses the empty String and returns null where the
predefined Java DateFormats throw an exception.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.DateFormat
DateFormat.Field -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DateFormatRefers 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
ConstructorsConstructorDescriptionAbstractWrappedDateFormat(DateFormat delegate) Constructs an AbstractWrappedDateFormat that wraps the given mandatory format. -
Method Summary
Modifier and TypeMethodDescriptionabstract StringBufferformat(Date date, StringBuffer toAppendTo, FieldPosition pos) booleanabstract Dateparse(String source, ParsePosition pos) voidsetCalendar(Calendar newCalendar) voidsetLenient(boolean lenient) voidsetNumberFormat(NumberFormat newNumberFormat) voidsetTimeZone(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, parseObjectMethods inherited from class java.text.Format
format, parseObject
-
Field Details
-
delegate
Refers to the wrapped Format that is used to forward#formatand#parseObject.
-
-
Constructor Details
-
AbstractWrappedDateFormat
Constructs an AbstractWrappedDateFormat that wraps the given mandatory format.- Parameters:
delegate- the format that handles the standard cases- Throws:
NullPointerException- ifdelegateisnull
-
-
Method Details
-
format
- Specified by:
formatin classDateFormat
-
parse
- Specified by:
parsein classDateFormat
-
getCalendar
- Overrides:
getCalendarin classDateFormat
-
setCalendar
- Overrides:
setCalendarin classDateFormat
-
getNumberFormat
- Overrides:
getNumberFormatin classDateFormat
-
setNumberFormat
- Overrides:
setNumberFormatin classDateFormat
-
getTimeZone
- Overrides:
getTimeZonein classDateFormat
-
setTimeZone
- Overrides:
setTimeZonein classDateFormat
-
isLenient
public boolean isLenient()- Overrides:
isLenientin classDateFormat
-
setLenient
public void setLenient(boolean lenient) - Overrides:
setLenientin classDateFormat
-
formatToCharacterIterator
- Overrides:
formatToCharacterIteratorin classFormat
-