|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.javaranch.common.JDate
Date is tracked as an integer.
Technically, a Julian calendar is the calendar designed by Julius Caesar in 46 B.C. It has months and leap years much like the gregorian calendar we use now (designed by Pope Gregory the 13th in 1582). But for several years, computer geeks have counted the number of days since the beginning of a year or another point in time and referred to this as a "Julian Date". From here on out, any reference to a "julian date" means "the number of days since January 1, 0000". This class will behave as if the Gregorian calendar leap year system has been in place since January 1, 0000.
This class will behave as both a Julian date and a Gregorian date although the actual date will be stored as a single integer.
- - - - - - - - - - - - - - - - -
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 | |
JDate()
Create a new JDate object with a default of zero. |
|
JDate(GDate g)
Create a new JDate object equal to a GDate object. |
|
JDate(int julianDate)
Create a new JDate object specified as the number of days since January 1, 0000. |
|
JDate(int year,
int month,
int day)
Create a new JDate object based on a year, month and day. |
|
JDate(JDate julianDate)
Create a new JDate object equal to another JDate object. |
Method Summary | |
void |
adjust(int adj)
Adjust the date by the given value. |
void |
dec()
Decrement the date by one. |
boolean |
equals(int julianDate)
Compare this object to an integer. |
boolean |
equals(java.lang.Object obj)
|
int |
get()
Get the integer representation. |
java.util.Date |
getDate()
Convert to a Date object. |
int |
getDay()
Get the day of the month (not the day of the week). |
int |
getDOW()
Get the day of the week (not the day of the month). |
java.lang.String |
getDOWString()
Get the full day of the week name: "Monday", "Tuesday", "Wednesday", etc. |
GDate |
getGDate()
Convert to a GDate object. |
java.lang.String |
getLongFormat()
Get something like "Wednesday, September 22, 1999". |
int |
getMonth()
Extract the month. |
java.lang.String |
getMonthString()
Get the full month name: "January", "February", "March", etc. |
java.lang.String |
getShortFormat()
Deprecated. |
int |
getYear()
Extract the year. |
int |
hashCode()
|
void |
inc()
Increment the date by one. |
void |
inc(int adjust)
Increment the date by the given value. |
static boolean |
isValid(GDate date)
Report if the given date is valid or not. |
void |
set(GDate g)
Set this object to be equal to a GDate object. |
void |
set(int newJulianDate)
Set this object to be equal to an integer. |
void |
set(JDate newJulianDate)
Set this object to be equal to another JDate object. |
void |
setDay(int newDay)
Change just the day - the year and month values will be unmodified. |
void |
setMonth(int newMonth)
Change just the month - the year and day values will be unmodified. |
void |
setYear(int newYear)
Change just the year - the month and day values will be unmodified. |
java.lang.String |
toString()
Returns the same thing as getLongFormat(). |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public JDate()
public JDate(int julianDate)
public JDate(JDate julianDate)
public JDate(int year, int month, int day)
public JDate(GDate g)
Method Detail |
public static boolean isValid(GDate date)
public void set(int newJulianDate)
public void set(JDate newJulianDate)
public void set(GDate g)
public void setYear(int newYear)
public void setMonth(int newMonth)
public void setDay(int newDay)
public int get()
public int getYear()
public int getMonth()
public java.lang.String getMonthString()
public int getDay()
public int getDOW()
Zero is monday.
public java.lang.String getDOWString()
public GDate getGDate()
public java.util.Date getDate()
Since a Date object has a time element, the time is set to noon.
public java.lang.String getShortFormat()
public java.lang.String getLongFormat()
public boolean equals(int julianDate)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public void inc()
public void inc(int adjust)
Negative values will decrement.
public void dec()
public void adjust(int adj)
Positive values will increment.
Negative values will decrement.
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |