Java java.util Date fields, constructors, methods, implement or subclass

Example usage for Java java.util Date fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.util Date.

The text is from its open source code.

Subclass

java.util.Date has subclasses.
Click this link to see all its subclasses.

Constructor

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.
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 method.
Date()
Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
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.

Method

booleanafter(Date when)
Tests if this date is after the specified date.
booleanbefore(Date when)
Tests if this date is before the specified date.
Objectclone()
Return a copy of this object.
intcompareTo(Date anotherDate)
Compares two Dates for ordering.
booleanequals(Object obj)
Compares two dates for equality.
Datefrom(Instant instant)
Obtains an instance of Date from an Instant object.
ClassgetClass()
Returns the runtime class of this Object .
intgetDate()
Returns the day of the month represented by this Date object.
intgetDay()
Returns the day of the week represented by this date.
intgetHours()
Returns the hour represented by this Date object.
intgetMinutes()
Returns the number of minutes past the hour represented by this date, as interpreted in the local time zone.
intgetMonth()
Returns a number representing the month that contains or begins with the instant in time represented by this Date object.
intgetSeconds()
Returns the number of seconds past the minute represented by this date.
longgetTime()
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.
intgetTimezoneOffset()
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.
intgetYear()
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.
inthashCode()
Returns a hash code value for this object.
longparse(String s)
Attempts to interpret the string s as a representation of a date and time.
voidsetDate(int date)
Sets the day of the month of this Date object to the specified value.
voidsetHours(int hours)
Sets the hour of this Date object to the specified value.
voidsetMinutes(int minutes)
Sets the minutes of this Date object to the specified value.
voidsetMonth(int month)
Sets the month of this date to the specified value.
voidsetSeconds(int seconds)
Sets the seconds of this Date to the specified value.
voidsetTime(long time)
Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.
voidsetYear(int year)
Sets the year of this Date object to be the specified value plus 1900.
StringtoGMTString()
Creates a string representation of this Date object of the form:
 d mon yyyy hh:mm:ss GMT
where:
  • d is the day of the month ( 1 through 31 ), as one or two decimal digits.
InstanttoInstant()
Converts this Date object to an Instant .
StringtoLocaleString()
Creates a string representation of this Date object in an implementation-dependent form.
StringtoString()
Converts this Date object to a String of the form:
 dow mon dd hh:mm:ss zzz yyyy
where:
  • dow is the day of the week ( Sun, Mon, Tue, Wed, Thu, Fri, Sat ).
longUTC(int year, int month, int date, int hrs, int min, int sec)
Determines the date and time based on the arguments.