public class Date extends Object implements Cloneable, Comparable, Serializable
Calendar
,
GregorianCalendar
,
DateFormat
,
Serialized FormConstructor and Description |
---|
Date()
Creates a new Date Object representing the current time.
|
Date(int year,
int month,
int day)
Deprecated.
use
new GregorianCalendar(year+1900, month,
day) instead. |
Date(int year,
int month,
int day,
int hour,
int min)
Deprecated.
use
new GregorianCalendar(year+1900, month,
day, hour, min) instead. |
Date(int year,
int month,
int day,
int hour,
int min,
int sec)
Deprecated.
use
new GregorianCalendar(year+1900, month,
day) instead. |
Date(long time)
Creates a new Date Object representing the given time.
|
Date(String s)
Deprecated.
use
java.text.DateFormat.parse(s) instead. |
Modifier and Type | Method and Description |
---|---|
boolean |
after(Date when)
Tests if this date is after the specified date.
|
boolean |
before(Date when)
Tests if this date is before the specified date.
|
Object |
clone()
Create a field for field copy of this Object if this Object
implements the Cloneable interface.
|
int |
compareTo(Date when)
Compares two dates.
|
int |
compareTo(Object obj)
Compares this Date to another.
|
boolean |
equals(Object obj)
Compares two dates for equality.
|
int |
getDate()
Deprecated.
Use Calendar instead of Date, and use get(Calendar.DATE)
instead.
|
int |
getDay()
Deprecated.
Use Calendar instead of Date, and use get(Calendar.DAY_OF_WEEK)
instead.
|
int |
getHours()
Deprecated.
Use Calendar instead of Date, and use get(Calendar.HOUR_OF_DAY)
instead.
|
int |
getMinutes()
Deprecated.
Use Calendar instead of Date, and use get(Calendar.MINUTE)
instead.
|
int |
getMonth()
Deprecated.
Use Calendar instead of Date, and use get(Calendar.MONTH)
instead.
|
int |
getSeconds()
Deprecated.
Use Calendar instead of Date, and use get(Calendar.SECOND)
instead.
|
long |
getTime()
Gets the time represented by this Object
|
int |
getTimezoneOffset()
Deprecated.
use
Calendar.get(Calendar.ZONE_OFFSET)+Calendar.get(Calendar.DST_OFFSET)
instead.
|
int |
getYear()
Deprecated.
Use Calendar instead of Date, and use get(Calendar.YEAR)
instead. Note about the 1900 difference in year.
|
int |
hashCode()
Returns a hashCode for the object.
|
static long |
parse(String string)
Deprecated.
Use DateFormat.parse(String)
|
void |
setDate(int date)
Deprecated.
Use Calendar instead of Date, and use
set(Calendar.DATE, date) instead.
|
void |
setHours(int hours)
Deprecated.
Use Calendar instead of Date, and use
set(Calendar.HOUR_OF_DAY, hours) instead.
|
void |
setMinutes(int minutes)
Deprecated.
Use Calendar instead of Date, and use
set(Calendar.MINUTE, minutes) instead.
|
void |
setMonth(int month)
Deprecated.
Use Calendar instead of Date, and use
set(Calendar.MONTH, month) instead.
|
void |
setSeconds(int seconds)
Deprecated.
Use Calendar instead of Date, and use
set(Calendar.SECOND, seconds) instead.
|
void |
setTime(long time)
Sets the time which this Object should represented.
|
void |
setYear(int year)
Deprecated.
Use Calendar instead of Date, and use
set(Calendar.YEAR, year) instead. Note about the 1900
difference in year.
|
String |
toGMTString()
Deprecated.
Use DateFormat.format(Date) with a GMT TimeZone.
|
String |
toLocaleString()
Deprecated.
Use DateFormat.format(Date)
|
String |
toString()
Return a String representation of this object.
|
static long |
UTC(int year,
int month,
int date,
int hrs,
int min,
int sec)
Deprecated.
Use Calendar with a UTC TimeZone instead.
|
public Date()
public Date(long time)
time
- the time in milliseconds since the epoch.public Date(int year, int month, int day)
new GregorianCalendar(year+1900, month,
day)
instead.public Date(int year, int month, int day, int hour, int min)
new GregorianCalendar(year+1900, month,
day, hour, min)
instead.public Date(int year, int month, int day, int hour, int min, int sec)
new GregorianCalendar(year+1900, month,
day)
instead.public Date(String s)
java.text.DateFormat.parse(s)
instead.new Date(Date.parse(s))
parse(java.lang.String)
public Object clone()
Object
public static long UTC(int year, int month, int date, int hrs, int min, int sec)
public long getTime()
public int getTimezoneOffset()
public void setTime(long time)
time
- the time in milliseconds since the epoch.public boolean after(Date when)
when
- the other datepublic boolean before(Date when)
when
- the other datepublic boolean equals(Object obj)
public int compareTo(Date when)
when
- the other date.public int compareTo(Object obj)
compareTo(Date)
, but it may throw a
ClassCastException
compareTo
in interface Comparable
obj
- the other date.ClassCastException
- if obj is not of type Date.public int hashCode()
Object
public String toString()
Object
public String toLocaleString()
public String toGMTString()
public static long parse(String string)
s
- The String to parse.public int getYear()
public void setYear(int year)
year
- the year minus 1900.public int getMonth()
public void setMonth(int month)
month
- the month, zero based.public int getDate()
public void setDate(int date)
date
- the date.public int getDay()
public int getHours()
public void setHours(int hours)
hours
- the hours.public int getMinutes()
public void setMinutes(int minutes)
minutes
- the minutes.public int getSeconds()
public void setSeconds(int seconds)
seconds
- the seconds.