# Class DateFormat

java.lang.Object
com.codename1.l10n.Format
com.codename1.l10n.DateFormat

All Implemented Interfaces:
  `Cloneable`

Direct Known Subclasses:
  `SimpleDateFormat`

public class DateFormat extends Format
A class for parsing and formatting localisation sensitive dates, compatible with Jave 6 SDK. This implementation uses the Codename One localization manager for handling formatting dates. Parsing dates is not implemented in this class since the localization pattern is not exposed.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `DEFAULT`
  Constant for default style (MEDIUM) parsing/formatting pattern.
  `static final int`
  `FULL`
  Constant for full style parsing/formatting pattern.
  `static final int`
  `LONG`
  Constant for long style parsing/formatting pattern.
  `static final int`
  `MEDIUM`
  Constant for medium style parsing/formatting pattern.
  `static final int`
  `SHORT`
  Constant for short style parsing/formatting pattern.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `clone()`
  `boolean`
  `equals(Object obj)`
  `String`
  `format(Object obj)`
  Format a given object.
  `String`
  `format(Date source)`
  Format a given date.
  `static final DateFormat`
  `getDateInstance()`
  Get a DateFormat instance with default style for date (SHORT).
  `static final DateFormat`
  `getDateInstance(int style)`
  Get a DateFormat instance that uses a given style for dates.
  `static final DateFormat`
  `getDateTimeInstance(int dateStyle, int timeStyle)`
  Get a DateFormat instance that uses a given style for dates and times.
  `static final DateFormat`
  `getInstance()`
  Get a DateFormat instance with default style for date/time (SHORT/SHORT).
  `static final DateFormat`
  `getTimeInstance()`
  Get a DateFormat instance with default style for time (SHORT).
  `static final DateFormat`
  `getTimeInstance(int style)`
  Get a DateFormat instance that uses a given style for times.
  `int`
  `hashCode()`
  `Date`
  `parse(String source)`
  NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.
  `Object`
  `parseObject(String source)`
  NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.

  ### Methods inherited from class Object

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

- ## Field Details

  - ### FULL

    public static final int FULL
    Constant for full style parsing/formatting pattern.
    See Also:
      - Constant Field Values

  - ### LONG

    public static final int LONG
    Constant for long style parsing/formatting pattern.
    See Also:
      - Constant Field Values

  - ### MEDIUM

    public static final int MEDIUM
    Constant for medium style parsing/formatting pattern.
    See Also:
      - Constant Field Values

  - ### SHORT

    public static final int SHORT
    Constant for short style parsing/formatting pattern.
    See Also:
      - Constant Field Values

  - ### DEFAULT

    public static final int DEFAULT
    Constant for default style (MEDIUM) parsing/formatting pattern.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### getInstance

    public static final DateFormat getInstance()

    Get a DateFormat instance with default style for date/time (SHORT/SHORT).

    ###### Returns

    a DateFormat instance.

  - ### getDateInstance

    public static final DateFormat getDateInstance()

    Get a DateFormat instance with default style for date (SHORT).

    ###### Returns

    a DateFormat instance.

  - ### getTimeInstance

    public static final DateFormat getTimeInstance()

    Get a DateFormat instance with default style for time (SHORT).

    ###### Returns

    a DateFormat instance.

  - ### getDateInstance

    public static final DateFormat getDateInstance(int style)

    Get a DateFormat instance that uses a given style for dates.

    ###### Parameters

    - `style`: style to use for parsing and formatting (SHORT, MEDIUM, LONG, FULL, DEFAULT);

    ###### Returns

    a DateFormat instance.

    ###### See also

    - #SHORT

    - #MEDIUM

    - #LONG

    - #FULL

    - #DEFAULT

  - ### getTimeInstance

    public static final DateFormat getTimeInstance(int style)

    Get a DateFormat instance that uses a given style for times.

    ###### Parameters

    - `style`: style to use for parsing and formatting (SHORT, MEDIUM, LONG, FULL, DEFAULT);

    ###### Returns

    a DateFormat instance.

    ###### See also

    - #SHORT

    - #MEDIUM

    - #LONG

    - #FULL

    - #DEFAULT

  - ### getDateTimeInstance

    public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle)

    Get a DateFormat instance that uses a given style for dates and times.

    ###### Parameters

    - `style`: style to use for parsing and formatting (SHORT, MEDIUM, LONG, FULL, DEFAULT);

    ###### Returns

    a DateFormat instance.

    ###### See also

    - #SHORT

    - #MEDIUM

    - #LONG

    - #FULL

    - #DEFAULT

  - ### format

    public String format(Object obj) throws IllegalArgumentException

    Format a given object.

    ###### Parameters

    - `obj`: object to be formatted.

    ###### Returns

    formatted object.

    ###### Throws

    - `IllegalArgumentException`: of the source can not be formatted.
    Specified by:
      `format` in class `Format`
    Throws:
      `IllegalArgumentException`

  - ### format

    public String format(Date source)

    Format a given date.

    ###### Parameters

    - `source`: date to be formatted.

    ###### Returns

    formatted date.

  - ### parseObject

    public Object parseObject(String source) throws ParseException
    NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.
    Specified by:
      `parseObject` in class `Format`
    Throws:
      `ParseException`

  - ### parse

    public Date parse(String source) throws ParseException
    NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.
    Throws:
      `ParseException`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### clone

    public Object clone()
    Overrides:
      `clone` in class `Object`