|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.javaranch.common.GDate
Gregorian Date, international format (YYYY/MM/DD).
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 international YYYY/MM/DD format. See ADate for MM/DD/YYYY format.
- - - - - - - - - - - - - - - - -
Copyright (c) 1998-2004 Paul Wheaton
You are welcome to do whatever you want to with this source file provided that you maintain this comment fragment (between the dashed lines). Modify it, change the package name, change the class name ... personal or business use ... sell it, share it ... add a copyright for the portions you add ...
My goal in giving this away and maintaining the copyright is to hopefully direct developers back to JavaRanch.
The original source can be found at JavaRanch
- - - - - - - - - - - - - - - - -
Constructor Summary | |
GDate()
Create a Gregorian Date object with a default of today's date. |
|
GDate(java.util.Date date)
|
|
GDate(GDate d)
Create a Gregorian Date object from another Gregorian Date object (GDate or ADate). |
|
GDate(int year,
int month,
int day)
Create a Gregorian Date object with a specific date. |
|
GDate(JDate j)
Create a Gregorian Date object with a specific Julian date. |
|
GDate(java.lang.String textDate)
Create a Gregorian Date object with a loosely formatted text date. |
|
GDate(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. |
boolean |
equals(java.lang.Object obj)
|
int |
getDay()
Return the day of the month (1..31). |
java.lang.String |
getFixedFormat()
Such as "2000/05/01". |
java.lang.String |
getLongFormat()
Returns a date formatted like "September 22, 1999". |
int |
getMonth()
|
java.lang.String |
getMonthString()
Get the full month name. |
static java.lang.String |
getMonthString(int month)
Convert a number 1 through 12 to a String "January" through "December". |
java.lang.String |
getShortFormat()
Deprecated. |
java.sql.Timestamp |
getTimestamp()
|
java.sql.Timestamp |
getTimestamp(java.util.TimeZone timeZone)
|
static GDate |
getToday(java.util.TimeZone timeZone)
|
int |
getYear()
|
void |
set(java.lang.String textDate)
Force the date based on the contents of a string. |
void |
setDay(int day)
Expects values 1..31 although invalid values are accepted. |
void |
setMonth(int month)
Expects values 1..12 although invalid values are accepted. |
void |
setToToday(java.util.TimeZone timeZone)
Set this object to reflect today's date. |
void |
setYear(int year)
|
java.lang.String |
toString()
Returns a date formatted like "2000/7/24". |
static java.lang.String |
toString(GDate g)
Returns a date formatted like "2000/7/24". |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public GDate()
public GDate(java.util.TimeZone timeZone)
public GDate(int year, int month, int day)
public GDate(JDate j)
public GDate(GDate d)
public GDate(java.lang.String textDate)
The general format is YYYY/MM/DD.
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.
public GDate(java.util.Date date)
Method Detail |
public void set(java.lang.String textDate)
The general format is YYYY/MM/DD.
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.
public void setToToday(java.util.TimeZone timeZone)
public void setYear(int year)
public void setMonth(int month)
public void setDay(int day)
public int getYear()
public int getMonth()
public static java.lang.String getMonthString(int month)
Passing in values outside of the 1 through 12 range will return an empty string.
public java.lang.String getMonthString()
If the current month is outside of the 1 through 12 range, an empty string will be returned.
Month names will be capitalized properly. e.g. "January".
public int getDay()
public java.lang.String getShortFormat()
public java.lang.String getFixedFormat()
public static java.lang.String toString(GDate g)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getLongFormat()
public java.sql.Timestamp getTimestamp()
public java.sql.Timestamp getTimestamp(java.util.TimeZone timeZone)
public java.lang.Object clone()
clone
in class java.lang.Object
public static GDate getToday(java.util.TimeZone timeZone)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |