API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.util. Date View Source
Author(s)
James Gosling
Arthur van Hoff
Alan Liu
Since
JDK1.0
Version
1.84, 11/23/06
Serial
Hierarchy
 Object
      Date
Implements
 Serializable
 Cloneable
 Comparable
Subclasses
Description
public class Date
  The class Date represents a specific instant in time, with millisecond precision.
See also:    DateFormat Calendar TimeZone
Constructors
public Date ()
  Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
@Deprecated
public Date (int year, int month, int date)
  Allocates a Date object and initializes it so that it represents midnight, local time, at the beginning of the day specified by the year, month, and date arguments.
@Deprecated
public Date (int year, int month, int date, int hrs, int min)
  Allocates a Date object and initializes it so that it represents the instant at the start of the minute specified by the year, month, date, hrs, and min arguments, in the local time zone.
@Deprecated
public Date (int year, int month, int date, int hrs, int min, int sec)
  Allocates a Date object and initializes it so that it represents the instant at the start of the second specified by the year, month, date, hrs, min, and sec arguments, in the local time zone.
public Date (long date)
  Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
@Deprecated
public Date (String s)
  Allocates a Date object and initializes it so that it represents the date and time indicated by the string s, which is interpreted as if by the Date.parse(java.lang.String) method.
Methods
Hide/Show inherited methods
public boolean after (Date when)
  Tests if this date is after the specified date.
public boolean before (Date when)
  Tests if this date is before the specified date.
public Object clone ()
Return a copy of this object.
public int compareTo (Date anotherDate)
  Compares two Dates for ordering.
public boolean equals (Object obj)
  Compares two dates for equality.
@Deprecated
public int getDate ()
  Returns the day of the month represented by this Date object.
@Deprecated
public int getDay ()
  Returns the day of the week represented by this date.
@Deprecated
public int getHours ()
  Returns the hour represented by this Date object.
pack-privatefinalstatic long getMillisOf (Date date)
Returns the millisecond value of this Date object without affecting its internal state.
@Deprecated
public int getMinutes ()
  Returns the number of minutes past the hour represented by this date, as interpreted in the local time zone.
@Deprecated
public int getMonth ()
  Returns a number representing the month that contains or begins with the instant in time represented by this Date object.
@Deprecated
public int getSeconds ()
  Returns the number of seconds past the minute represented by this date.
public long getTime ()
  Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.
@Deprecated
public int getTimezoneOffset ()
  Returns the offset, measured in minutes, for the local time zone relative to UTC that is appropriate for the time represented by this Date object.
@Deprecated
public int getYear ()
  Returns a value that is the result of subtracting 1900 from the year that contains or begins with the instant in time represented by this Date object, as interpreted in the local time zone.
public int hashCode ()
  Returns a hash code value for this object.
@Deprecated
publicstatic long parse (String s)
  Attempts to interpret the string s as a representation of a date and time.
@Deprecated
public void setDate (int date)
  Sets the day of the month of this Date object to the specified value.
@Deprecated
public void setHours (int hours)
  Sets the hour of this Date object to the specified value.
@Deprecated
public void setMinutes (int minutes)
  Sets the minutes of this Date object to the specified value.
@Deprecated
public void setMonth (int month)
  Sets the month of this date to the specified value.
@Deprecated
public void setSeconds (int seconds)
  Sets the seconds of this Date to the specified value.
public void setTime (long time)
  Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.
@Deprecated
public void setYear (int year)
  Sets the year of this Date object to be the specified value plus 1900.
@Deprecated
public String toGMTString ()
  Creates a string representation of this Date object of the form:
where:
  • d is the day of the month (1 through 31), as one or two decimal digits.
  • mon is the month (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec).
  • yyyy is the year, as four decimal digits.
  • hh is the hour of the day (00 through 23), as two decimal digits.
  • mm is the minute within the hour (00 through 59), as two decimal digits.
  • ss is the second within the minute (00 through 61), as two decimal digits.
  • GMT is exactly the ASCII letters "GMT" to indicate Greenwich Mean Time.

The result does not depend on the local time zone.
Returns: a string representation of this date, using the Internet GMT conventions.
See Also: DateFormat, Date.toString(), Date.toLocaleString(),

@Deprecated
public String toLocaleString ()
  Creates a string representation of this Date object in an implementation-dependent form.
public String toString ()
  Converts this Date object to a String of the form:
@Deprecated
publicstatic long UTC (int year, int month, int date, int hrs, int min, int sec)
  Determines the date and time based on the arguments.
Fields
Hide/Show inherited fields
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar