# com.bea.p13n.xml.schema
Date Class

public class Date
extends `Month`
implements `Cloneable`, `Comparable`, `Serializable`

This class provides the Java biding for the XML schema type date as specified in Section 3.3.27 of XML Schema Part 2: Datatypes.

date represents a specific period of time that starts at midnight and lasts until the mignight the following day.

The value space of month is the set of Gregorian calendar dates specified as CCYY-MM-DD.

Example: `2001-01-01`.

Hierarchy
  `Object`
  `Century`
  `Year`
  `Month`
  `Date`

All Implemented Interfaces
  `Cloneable`, `Comparable`, `Serializable`

## Field Summary

Fields from com.bea.p13n.xml.schema`.`Century``
``_internal``

## Constructor Summary

Date() Constructs a new Date instance.
Date(long year, int month, int day, `TimeZone` timeZone) Constructs a new Date for the given year, month, date and timezone.

## Method Summary

`public `Object`` | `clone`() Returns a copy of this date.
`public int` | `compareTo`(`Date` anotherDate) Compares this Date to another Date object (represented in the same time zone) in their canonical representation.
`public int` | `compareTo`(`Object` anotherObject) Compares this Date with another object.
`public static `Date`` | `createDate`() Returns a Date instance for today.
`public static `Date`` | `createDate`(`String` date) Given a string of the form CCYY-MM-DD, returns a Date instance.
`public static `Date`` | `createDate`(`Date` date) Given a java.util.Date, returns a Date instance.
`public static `Date`` | `createDate`(long year, int month, int day, `TimeZone` timeZone) Given the given year, month, date and timezone, returns a Date instance.
`public int` | `getDay`() Returns the day (DD) field
`public void` | `setDay`(int day) Sets the month (DD) field
`public `Date`` | `toSQLDate`() Returns a `java.sql.Date` equivalent.
`public `String`` | `toString`() Returns a XML schema compliant date string.
`public `Object`` | `toUTC`() Offsets the current date instant to UTC.

Methods from `com.bea.p13n.xml.schema.`Month``
``compareTo`, `createMonth`, `createMonth`, `getMonth`, `setMonth`,`

Methods from `com.bea.p13n.xml.schema.`Year``
``clone`, `compareTo`, `compareTo`, `createYear`, `createYear`, `getYear`, `setYear`, `setYear`, `toString`, `toUTC``

Methods from `com.bea.p13n.xml.schema.`Century``
``clone`, `compareTo`, `compareTo`, `createCentury`, `createCentury`, `getCentury`, `getEra`, `getTimeZone`, `setCentury`, `setEra`, `setTimeZone`, `setTimeZone`, `toString`, `toUTC``

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods from interface `java.lang.`Comparable``
`compareTo`

## Constructor Detail

### Date

    protected Date()

  Constructs a new Date instance.

### Date

    protected Date(long year,
                   int month,
                   int day,
                   TimeZone timeZone)

  Constructs a new Date for the given year, month, date and timezone.

## Method Detail

### clone() Method

    public Object clone()

Returns a copy of this date.

Overrides
  `Month.clone()`

#### Returns

copy

### compareTo(Date) Method

    public int compareTo(Date anotherDate)

Compares this Date to another Date object (represented in the same time zone) in their canonical representation.

#### Parameters

anotherDate
  another Date object to be compared.

#### Returns

the value 0 if the argument Date is equal to this Date; a value less than 0 if this Date is before the Date argument; and a value greater than 0 if this Date is after the Date argument.

### compareTo(Object) Method

    public int compareTo(Object anotherObject)

Compares this Date with another object. If the other object is a Date, this method behaves like compareTo(Date). Otherwise, it throws a ClassCastException.

Overrides
  `Month.compareTo(Object)`

#### Parameters

anotherObject
  the object to be compared

#### Returns

the value 0 if the argument Date is equal to this Date; a value less than 0 if this Date is before the Date argument; and a value greater than 0 if this Date is after the Date argument.

### createDate() Method

    public static Date createDate()

Returns a Date instance for today.

#### Returns

instance of Date

### createDate(String) Method

    public static Date createDate(String date)
         throws ParseException

Given a string of the form CCYY-MM-DD, returns a Date instance.

#### Returns

instance of Date

#### Exceptions

``ParseException``

### createDate(Date) Method

    public static Date createDate(Date date)

Given a java.util.Date, returns a Date instance.

#### Parameters

date
  date

#### Returns

instance of Date

### createDate(long, int, int, TimeZone) Method

    public static Date createDate(long year,
                                  int month,
                                  int day,
                                  TimeZone timeZone)

Given the given year, month, date and timezone, returns a Date instance.

#### Parameters

year
  the year (CCYY) field

month
  the month (MM) field

day
  the day (DD) field

timeZone
  the timezone. May be null if local.

#### Returns

instance of Date

### getDay() Method

    public int getDay()

Returns the day (DD) field

#### Returns

the day

### setDay(int) Method

    public void setDay(int day)
         throws IllegalArgumentException

Sets the month (DD) field

#### Parameters

day
  the day (DD)

#### Exceptions

``IllegalArgumentException``
  thrown when the day argument is illegal

### toSQLDate() Method

    public Date toSQLDate()

Returns a `java.sql.Date` equivalent. Note that this operation excludes any timezone.

#### Returns

java.sql.Date

### toString() Method

    public String toString()

Returns a XML schema compliant date string.

Overrides
  `Month.toString()`

#### Returns

string value

### toUTC() Method

    public Object toUTC()

Offsets the current date instant to UTC.

Overrides
  `Month.toUTC()`

#### Returns

instance of Date offset to UTC