|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjd.util.Date
A class for storing date values. Easier to use than java.util.Calendar and not so deprecated as java.util.Date.
Field Summary | |
static int |
WEEKDAY_FRIDAY
|
static int |
WEEKDAY_MONDAY
|
static int |
WEEKDAY_SATURDAY
|
static int |
WEEKDAY_SUNDAY
|
static int |
WEEKDAY_THURSDAY
|
static int |
WEEKDAY_TUESDAY
|
static int |
WEEKDAY_WEDNESDAY
|
Constructor Summary | |
Date()
Create a Date object for current date. |
|
Date(Calendar cal)
Create a date from a Calendar. |
|
Date(Date date)
Create a date from another date. |
|
Date(Date date)
Create a date from a java.util.Date. |
|
Date(int year,
int month,
int day)
Create a new Date. |
|
Date(long time)
Creates a Date object for the given system time. |
Method Summary | |
Date |
addDays(int days)
Return a new Date object representing this date plus the given amount of days. |
Date |
addMonths(int months)
Return a new Date object representing this date plus the given amount of months. |
Date |
addYears(int years)
Return a new Date object representing this date plus the given amount of years. |
Object |
clone()
Clone this date. |
int |
difference(Date date)
Calculate the difference in days between two dates. |
boolean |
equals(Object date)
Test if this date is equal to another date. |
static Date |
fromInteger(int value)
Extract a date from an integer. |
int |
getDay()
Return the day value (ranging from 1 to 31). |
int |
getDayOfWeek()
|
int |
getLastDayOfMonth()
Returns the value for the last day of the month of this date (ranging from 28 to 31). |
static int |
getLastDayOfMonth(int month,
int year)
Returns the last day of the month for the given month and year (ranging from 28 to 31). |
int |
getMonth()
Return the month value (ranging from 1 to 12). |
int |
getYear()
Return the year value. |
int |
hashCode()
Get a hashcode for the date. |
boolean |
isAfter(Date d)
Test if this date is after the given date. |
boolean |
isBefore(Date d)
Test if this date is before the given date. |
boolean |
isLeapYear()
Tests if the year of this date is a leap year. |
static boolean |
isLeapYear(int year)
Test if the given year is a leap year. |
static boolean |
isValidDate(int year,
int month,
int day)
Test if the given values represent a valid date. |
Calendar |
toCalendar()
Convert the date to an Calendar. |
static Date |
today()
Return a Date object for the current date. |
int |
toInteger()
Return an integer representation of this date. |
static int |
toInteger(int day,
int month,
int year)
Return an integer representation of the given date values. |
Date |
toJavaDate()
Convert the date to an java.util.Date. |
Date |
toJavaSqlDate()
Convert the date to an java.sql.Date. |
int |
toJulianDayNumber()
Convert a date (more accurate: the noon of this date) to its Julian Day Number. |
String |
toString()
Return a string representation of this date in the form yyyymmdd. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int WEEKDAY_SUNDAY
public static final int WEEKDAY_MONDAY
public static final int WEEKDAY_TUESDAY
public static final int WEEKDAY_WEDNESDAY
public static final int WEEKDAY_THURSDAY
public static final int WEEKDAY_FRIDAY
public static final int WEEKDAY_SATURDAY
Constructor Detail |
public Date()
public Date(long time)
public Date(int year, int month, int day)
year
- the year (the year 2001 is specified as 2001)month
- the month (counting from 1 to 12)day
- the day (counting from 1 to 31)
IllegalArgumentException
- thrown if the values represent
an invalid datepublic Date(Date date)
public Date(Date date)
public Date(Calendar cal)
Method Detail |
public static Date today()
public int getDay()
public int getMonth()
public int getYear()
public int getLastDayOfMonth()
public static int getLastDayOfMonth(int month, int year)
public boolean isLeapYear()
public static boolean isLeapYear(int year)
public int getDayOfWeek()
public boolean equals(Object date)
public boolean isBefore(Date d)
public boolean isAfter(Date d)
public Date addYears(int years)
public Date addMonths(int months)
public Date addDays(int days)
public int difference(Date date)
public static boolean isValidDate(int year, int month, int day)
public String toString()
DateFormat
public Calendar toCalendar()
public Date toJavaDate()
public Date toJavaSqlDate()
public int toInteger()
public static int toInteger(int day, int month, int year)
public static Date fromInteger(int value)
toInteger()
public int toJulianDayNumber()
public Object clone()
public int hashCode()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |