com.javaranch.common
Class ADate

java.lang.Object
  |
  +--com.javaranch.common.GDate
        |
        +--com.javaranch.common.ADate

public class ADate
extends GDate

Gregorian Date, american format (MM/DD/YYYY).

These dates are stored as Year, Month and Day. Not very memory efficient, but good for converting to strings, or quickly extracting the day of the month.

See the complimentary class JDate for memory efficiency or doing date math.

This object uses the american MM/DD/YYYY format. See GDate for YYYY/MM/DD format.

Author:
Paul Wheaton

Constructor Summary
ADate()
          Create a Gregorian Date object with a default of today's date.
ADate(GDate d)
          Create a Gregorian Date object from another Gregorian Date object (GDate or ADate).
ADate(int year, int month, int day)
          Create a Gregorian Date object with a specific date.
ADate(JDate j)
          Create a Gregorian Date object with a specific Julian date.
ADate(java.lang.String textDate)
          Create a Gregorian Date object with a loosely formatted text date.
ADate(java.sql.Timestamp t)
          Create a Gregorian Date object based on today's date.
ADate(java.util.TimeZone timeZone)
          Create a Gregorian Date object with a default of today's date.
 
Method Summary
 java.lang.Object clone()
          Get a copy of this object.
 java.lang.String getFixedFormat()
          Such as "05/01/2000".
static java.sql.Timestamp getTimestamp(java.lang.String textDate)
           
 void set(java.lang.String textDate)
          Force the date based on the contents of a string.
 java.lang.String toString()
          Returns a date formatted like "7/24/2000".
static java.lang.String toString(GDate g)
          Returns a date formatted like "7/24/2000".
 
Methods inherited from class com.javaranch.common.GDate
equals, getDay, getLongFormat, getMonth, getMonthString, getMonthString, getShortFormat, getTimestamp, getTimestamp, getToday, getYear, setDay, setMonth, setToToday, setYear
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ADate

public ADate(java.util.TimeZone timeZone)
Create a Gregorian Date object with a default of today's date.


ADate

public ADate()
Create a Gregorian Date object with a default of today's date.


ADate

public ADate(int year,
             int month,
             int day)
Create a Gregorian Date object with a specific date.


ADate

public ADate(JDate j)
Create a Gregorian Date object with a specific Julian date.


ADate

public ADate(GDate d)
Create a Gregorian Date object from another Gregorian Date object (GDate or ADate).


ADate

public ADate(java.sql.Timestamp t)
Create a Gregorian Date object based on today's date.


ADate

public ADate(java.lang.String textDate)
Create a Gregorian Date object with a loosely formatted text date.

The general format is MM/DD/YYYY.

Any type of delimiter can be used (slash, hyphen, space, etc.). The month and date does not have to be two digits in length. The year does not have to be four digits in length, although "98" will be interpretted as 0098, not 1998 or 2098.

Invalid dates are accepted.

Method Detail

set

public void set(java.lang.String textDate)
Force the date based on the contents of a string.

The general format is DD/MM/YYYY.

Any type of delimiter can be used (slash, hyphen, space, etc.). The month and date does not have to be two digits in length. The year does not have to be four digits in length, although "98" will be interpretted as 0098, not 1998 or 2098.

Invalid dates are accepted.

If you leave out the day of the month, the first is assumed.

If you leave out the month, January is assumed.

Overrides:
set in class GDate

getFixedFormat

public java.lang.String getFixedFormat()
Such as "05/01/2000".

Overrides:
getFixedFormat in class GDate

toString

public static java.lang.String toString(GDate g)
Returns a date formatted like "7/24/2000".


toString

public java.lang.String toString()
Returns a date formatted like "7/24/2000".

Overrides:
toString in class GDate

clone

public java.lang.Object clone()
Get a copy of this object.

Overrides:
clone in class GDate

getTimestamp

public static java.sql.Timestamp getTimestamp(java.lang.String textDate)


Copyright ©2004 Paul Wheaton All Rights Reserved