AbstractWrappedDateFormat (JGoodies Common 1.8 API)
Date: 2015-01-03

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

      public abstract class AbstractWrappedDateFormat
      extends DateFormat

  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.

  Author:
    Karsten Lentzsch
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.text.DateFormat

      `DateFormat.Field`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected DateFormat` | `delegate` Refers to the wrapped Format that is used to forward `#format` and `#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 and Description
    `AbstractWrappedDateFormat(DateFormat delegate)` Constructs an AbstractWrappedDateFormat that wraps the given mandatory format.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract StringBuffer` | `format(Date date, StringBuffer toAppendTo, FieldPosition pos)`
    `AttributedCharacterIterator` | `formatToCharacterIterator(Object obj)`
    `Calendar` | `getCalendar()`
    `NumberFormat` | `getNumberFormat()`
    `TimeZone` | `getTimeZone()`
    `boolean` | `isLenient()`
    `abstract Date` | `parse(String source, ParsePosition pos)`
    `void` | `setCalendar(Calendar newCalendar)`
    `void` | `setLenient(boolean lenient)`
    `void` | `setNumberFormat(NumberFormat newNumberFormat)`
    `void` | `setTimeZone(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`

    - ### Methods inherited from class java.text.Format

      `format, parseObject`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### delegate

          protected final DateFormat delegate

      Refers to the wrapped Format that is used to forward `#format` and `#parseObject`.

  - ### Constructor Detail

    - #### AbstractWrappedDateFormat

          public AbstractWrappedDateFormat(DateFormat delegate)

      Constructs an AbstractWrappedDateFormat that wraps the given mandatory format.
      Parameters:
        `delegate` - the format that handles the standard cases
      Throws:
        `NullPointerException` - if `delegate` is `null`

  - ### Method Detail

    - #### format

          public abstract StringBuffer format(Date date,
                            StringBuffer toAppendTo,
                            FieldPosition pos)

      Specified by:
        `format` in class `DateFormat`

    - #### parse

          public abstract Date parse(String source,
                   ParsePosition pos)

      Specified by:
        `parse` in class `DateFormat`

    - #### getCalendar

          public Calendar getCalendar()

      Overrides:
        `getCalendar` in class `DateFormat`

    - #### setCalendar

          public void setCalendar(Calendar newCalendar)

      Overrides:
        `setCalendar` in class `DateFormat`

    - #### getNumberFormat

          public NumberFormat getNumberFormat()

      Overrides:
        `getNumberFormat` in class `DateFormat`

    - #### setNumberFormat

          public void setNumberFormat(NumberFormat newNumberFormat)

      Overrides:
        `setNumberFormat` in class `DateFormat`

    - #### getTimeZone

          public TimeZone getTimeZone()

      Overrides:
        `getTimeZone` in class `DateFormat`

    - #### setTimeZone

          public void setTimeZone(TimeZone zone)

      Overrides:
        `setTimeZone` in class `DateFormat`

    - #### isLenient

          public boolean isLenient()

      Overrides:
        `isLenient` in class `DateFormat`

    - #### setLenient

          public void setLenient(boolean lenient)

      Overrides:
        `setLenient` in class `DateFormat`

    - #### formatToCharacterIterator

          public AttributedCharacterIterator formatToCharacterIterator(Object obj)

      Overrides:
        `formatToCharacterIterator` in class `Format`

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