Class Date (2.12.0)

public final class Date implements Comparable<Date>, Serializable

Represents a Date without time, such as 2017-03-17. Date is timezone independent.

Inheritance

Object > Date

Static Methods

fromJavaUtilDate(Date date)

public static Date fromJavaUtilDate(Date date)

Convert a Java Util Date to a Google Date.

Parameter
NameDescription
dateDate

the date of the java.util.Date

Returns
TypeDescription
Date

Google Java Date

fromYearMonthDay(int year, int month, int dayOfMonth)

public static Date fromYearMonthDay(int year, int month, int dayOfMonth)

Constructs a new Date instance.

Parameters
NameDescription
yearint

must be greater than 0

monthint

must be between [1,12]

dayOfMonthint

must be between [1,31]

Returns
TypeDescription
Date

parseDate(String date)

public static Date parseDate(String date)
Parameter
NameDescription
dateString

Data in RFC 3339 date format (yyyy-mm-dd).

Returns
TypeDescription
Date

toJavaUtilDate(Date date)

public static Date toJavaUtilDate(Date date)

Convert a Google Date to a Java Util Date.

Parameter
NameDescription
dateDate

the date of the Google Date.

Returns
TypeDescription
Date

java.util.Date

Methods

compareTo(Date other)

public int compareTo(Date other)
Parameter
NameDescription
otherDate
Returns
TypeDescription
int

equals(Object o)

public boolean equals(Object o)
Parameter
NameDescription
oObject
Returns
TypeDescription
boolean
Overrides

getDayOfMonth()

public int getDayOfMonth()

Returns day of month between 1 and 31 inclusive.

Returns
TypeDescription
int

getMonth()

public int getMonth()

Returns the month between 1 and 12 inclusive.

Returns
TypeDescription
int

getYear()

public int getYear()

Returns the year.

Returns
TypeDescription
int

hashCode()

public int hashCode()
Returns
TypeDescription
int
Overrides

toString()

public String toString()
Returns
TypeDescription
String
Overrides