Build 1.1_r1 (from source)

java.util
Class Date

java.lang.Object
  extended by java.util.Date
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Date>
Direct Known Subclasses:
Date, Time, Timestamp

public class Date
extends Object
implements Serializable, Cloneable, Comparable<Date>

Date represents a specific moment in time, to the millisecond.

Since:
Android 1.0
See Also:
System.currentTimeMillis(), Calendar, GregorianCalendar, SimpleTimeZone, TimeZone, Serialized Form

Constructor Summary
Date()
          Initializes this Date instance to the current date and time.
Date(int year, int month, int day)
          Deprecated. use GregorianCalendar.GregorianCalendar(int, int, int)
Date(int year, int month, int day, int hour, int minute)
          Deprecated. use GregorianCalendar.GregorianCalendar(int, int, int, int, int)
Date(int year, int month, int day, int hour, int minute, int second)
          Deprecated. use GregorianCalendar.GregorianCalendar(int, int, int, int, int, int)
Date(long milliseconds)
          Initializes this Date instance using the specified millisecond value.
Date(String string)
          Deprecated. use DateFormat
 
Method Summary
 boolean after(Date date)
          Returns if this Date is after the specified Date.
 boolean before(Date date)
          Returns if this Date is before the specified Date.
 Object clone()
          Returns a new Date with the same millisecond value as this Date.
 int compareTo(Date date)
          Compare the receiver to the specified Date to determine the relative ordering.
 boolean equals(Object object)
          Compares the specified object to this Date and returns if they are equal.
 int getDate()
          Deprecated. use Calendar.get(Calendar.DATE)
 int getDay()
          Deprecated. use Calendar.get(Calendar.DAY_OF_WEEK)
 int getHours()
          Deprecated. use Calendar.get(Calendar.HOUR_OF_DAY)
 int getMinutes()
          Deprecated. use Calendar.get(Calendar.MINUTE)
 int getMonth()
          Deprecated. use Calendar.get(Calendar.MONTH)
 int getSeconds()
          Deprecated. use Calendar.get(Calendar.SECOND)
 long getTime()
          Returns this Date as a millisecond value.
 int getTimezoneOffset()
          Deprecated. use (Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / 60000
 int getYear()
          Deprecated. use Calendar.get(Calendar.YEAR) - 1900
 int hashCode()
          Returns an integer hash code for the receiver.
static long parse(String string)
          Deprecated. use DateFormat
 void setDate(int day)
          Deprecated. use Calendar.set(Calendar.DATE, day)
 void setHours(int hour)
          Deprecated. use Calendar.set(Calendar.HOUR_OF_DAY, hour)
 void setMinutes(int minute)
          Deprecated. use Calendar.set(Calendar.MINUTE, minute)
 void setMonth(int month)
          Deprecated. use Calendar.set(Calendar.MONTH, month)
 void setSeconds(int second)
          Deprecated. use Calendar.set(Calendar.SECOND, second)
 void setTime(long milliseconds)
          Sets this Date to the specified millisecond value.
 void setYear(int year)
          Deprecated. use Calendar.set(Calendar.YEAR, year + 1900)
 String toGMTString()
          Deprecated. use DateFormat
 String toLocaleString()
          Deprecated. use DateFormat
 String toString()
          Returns the string representation of this Date in the format: Tue Jun 22 13:07:00 GMT 1999
static long UTC(int year, int month, int day, int hour, int minute, int second)
          Deprecated. use: Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); cal.set(year + 1900, month, day, hour, minute, second); cal.getTime().getTime();
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Date

public Date()
Initializes this Date instance to the current date and time.

Since:
Android 1.0

Date

@Deprecated
public Date(int year,
                       int month,
                       int day)
Deprecated. use GregorianCalendar.GregorianCalendar(int, int, int)

Constructs a new Date initialized to midnight in the default TimeZone on the specified date.

Parameters:
year - the year, 0 is 1900.
month - the month, 0 - 11.
day - the day of the month, 1 - 31.
Since:
Android 1.0

Date

@Deprecated
public Date(int year,
                       int month,
                       int day,
                       int hour,
                       int minute)
Deprecated. use GregorianCalendar.GregorianCalendar(int, int, int, int, int)

Constructs a new Date initialized to the specified date and time in the default TimeZone.

Parameters:
year - the year, 0 is 1900.
month - the month, 0 - 11.
day - the day of the month, 1 - 31.
hour - the hour of day, 0 - 23.
minute - the minute of the hour, 0 - 59.
Since:
Android 1.0

Date

@Deprecated
public Date(int year,
                       int month,
                       int day,
                       int hour,
                       int minute,
                       int second)
Deprecated. use GregorianCalendar.GregorianCalendar(int, int, int, int, int, int)

Constructs a new Date initialized to the specified date and time in the default TimeZone.

Parameters:
year - the year, 0 is 1900.
month - the month, 0 - 11.
day - the day of the month, 1 - 31.
hour - the hour of day, 0 - 23.
minute - the minute of the hour, 0 - 59.
second - the second of the minute, 0 - 59.
Since:
Android 1.0

Date

public Date(long milliseconds)
Initializes this Date instance using the specified millisecond value. The value is the number of milliseconds since Jan. 1, 1970 GMT.

Parameters:
milliseconds - the number of milliseconds since Jan. 1, 1970 GMT.
Since:
Android 1.0

Date

@Deprecated
public Date(String string)
Deprecated. use DateFormat

Constructs a new Date initialized to the date and time parsed from the specified String.

Parameters:
string - the String to parse.
Since:
Android 1.0
Method Detail

after

public boolean after(Date date)
Returns if this Date is after the specified Date.

Parameters:
date - a Date instance to compare.
Returns:
true if this Date is after the specified Date, false otherwise.
Since:
Android 1.0

before

public boolean before(Date date)
Returns if this Date is before the specified Date.

Parameters:
date - a Date instance to compare.
Returns:
true if this Date is before the specified Date, false otherwise.
Since:
Android 1.0

clone

public Object clone()
Returns a new Date with the same millisecond value as this Date.

Overrides:
clone in class Object
Returns:
a shallow copy of this Date.
Since:
Android 1.0
See Also:
Cloneable

compareTo

public int compareTo(Date date)
Compare the receiver to the specified Date to determine the relative ordering.

Specified by:
compareTo in interface Comparable<Date>
Parameters:
date - a Date to compare against.
Returns:
an int < 0 if this Date is less than the specified Date, 0 if they are equal, and an int > 0 if this Date is greater.
Since:
Android 1.0

equals

public boolean equals(Object object)
Compares the specified object to this Date and returns if they are equal. To be equal, the object must be an instance of Date and have the same millisecond value.

Overrides:
equals in class Object
Parameters:
object - the object to compare with this object.
Returns:
true if the specified object is equal to this Date, false otherwise.
Since:
Android 1.0
See Also:
hashCode()

getDate

@Deprecated
public int getDate()
Deprecated. use Calendar.get(Calendar.DATE)

Returns the gregorian calendar day of the month for this Date object.

Returns:
the day of the month.
Since:
Android 1.0

getDay

@Deprecated
public int getDay()
Deprecated. use Calendar.get(Calendar.DAY_OF_WEEK)

Returns the gregorian calendar day of the week for this Date object.

Returns:
the day of the week.
Since:
Android 1.0

getHours

@Deprecated
public int getHours()
Deprecated. use Calendar.get(Calendar.HOUR_OF_DAY)

Returns the gregorian calendar hour of the day for this Date object.

Returns:
the hour of the day.
Since:
Android 1.0

getMinutes

@Deprecated
public int getMinutes()
Deprecated. use Calendar.get(Calendar.MINUTE)

Returns the gregorian calendar minute of the hour for this Date object.

Returns:
the minutes.
Since:
Android 1.0

getMonth

@Deprecated
public int getMonth()
Deprecated. use Calendar.get(Calendar.MONTH)

Returns the gregorian calendar month for this Date object.

Returns:
the month.
Since:
Android 1.0

getSeconds

@Deprecated
public int getSeconds()
Deprecated. use Calendar.get(Calendar.SECOND)

Returns the gregorian calendar second of the minute for this Date object.

Returns:
the seconds.
Since:
Android 1.0

getTime

public long getTime()
Returns this Date as a millisecond value. The value is the number of milliseconds since Jan. 1, 1970, midnight GMT.

Returns:
the number of milliseconds since Jan. 1, 1970, midnight GMT.
Since:
Android 1.0

getTimezoneOffset

@Deprecated
public int getTimezoneOffset()
Deprecated. use (Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / 60000

Returns the timezone offset in minutes of the default TimeZone.

Returns:
the timezone offset in minutes of the default TimeZone.
Since:
Android 1.0

getYear

@Deprecated
public int getYear()
Deprecated. use Calendar.get(Calendar.YEAR) - 1900

Returns the gregorian calendar year since 1900 for this Date object.

Returns:
the year - 1900.
Since:
Android 1.0

hashCode

public int hashCode()
Returns an integer hash code for the receiver. Objects which are equal return the same value for this method.

Overrides:
hashCode in class Object
Returns:
this Date's hash.
Since:
Android 1.0
See Also:
equals(java.lang.Object)

parse

@Deprecated
public static long parse(String string)
Deprecated. use DateFormat

Returns the millisecond value of the date and time parsed from the specified String. Many date/time formats are recognized, including IETF standard syntax, i.e. Tue, 22 Jun 1999 12:16:00 GMT-0500

Parameters:
string - the String to parse.
Returns:
the millisecond value parsed from the String.
Since:
Android 1.0

setDate

@Deprecated
public void setDate(int day)
Deprecated. use Calendar.set(Calendar.DATE, day)

Sets the gregorian calendar day of the month for this Date object.

Parameters:
day - the day of the month.
Since:
Android 1.0

setHours

@Deprecated
public void setHours(int hour)
Deprecated. use Calendar.set(Calendar.HOUR_OF_DAY, hour)

Sets the gregorian calendar hour of the day for this Date object.

Parameters:
hour - the hour of the day.
Since:
Android 1.0

setMinutes

@Deprecated
public void setMinutes(int minute)
Deprecated. use Calendar.set(Calendar.MINUTE, minute)

Sets the gregorian calendar minute of the hour for this Date object.

Parameters:
minute - the minutes.
Since:
Android 1.0

setMonth

@Deprecated
public void setMonth(int month)
Deprecated. use Calendar.set(Calendar.MONTH, month)

Sets the gregorian calendar month for this Date object.

Parameters:
month - the month.
Since:
Android 1.0

setSeconds

@Deprecated
public void setSeconds(int second)
Deprecated. use Calendar.set(Calendar.SECOND, second)

Sets the gregorian calendar second of the minute for this Date object.

Parameters:
second - the seconds.
Since:
Android 1.0

setTime

public void setTime(long milliseconds)
Sets this Date to the specified millisecond value. The value is the number of milliseconds since Jan. 1, 1970 GMT.

Parameters:
milliseconds - the number of milliseconds since Jan. 1, 1970 GMT.
Since:
Android 1.0

setYear

@Deprecated
public void setYear(int year)
Deprecated. use Calendar.set(Calendar.YEAR, year + 1900)

Sets the gregorian calendar year since 1900 for this Date object.

Parameters:
year - the year since 1900.
Since:
Android 1.0

toGMTString

@Deprecated
public String toGMTString()
Deprecated. use DateFormat

Returns the string representation of this Date in GMT in the format: 22 Jun 1999 13:02:00 GMT

Returns:
the string representation of this Date in GMT.
Since:
Android 1.0

toLocaleString

@Deprecated
public String toLocaleString()
Deprecated. use DateFormat

Returns the string representation of this Date for the default Locale.

Returns:
the string representation of this Date for the default Locale.
Since:
Android 1.0

toString

public String toString()
Returns the string representation of this Date in the format: Tue Jun 22 13:07:00 GMT 1999

Overrides:
toString in class Object
Returns:
the string representation of this Date.
Since:
Android 1.0

UTC

@Deprecated
public static long UTC(int year,
                                  int month,
                                  int day,
                                  int hour,
                                  int minute,
                                  int second)
Deprecated. use: Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); cal.set(year + 1900, month, day, hour, minute, second); cal.getTime().getTime();

Returns the millisecond value of the specified date and time in GMT.

Parameters:
year - the year, 0 is 1900.
month - the month, 0 - 11.
day - the day of the month, 1 - 31.
hour - the hour of day, 0 - 23.
minute - the minute of the hour, 0 - 59.
second - the second of the minute, 0 - 59.
Returns:
the date and time in GMT in milliseconds.
Since:
Android 1.0

Build 1.1_r1 (from source)

Please submit a feedback, bug or feature