public final class LocalDate extends Object
Note that ISO 8601 has a number of differences with the default gregorian calendar used in Java:
This class implements these differences, so that year/month/day fields match exactly the ones in CQL string literals.
Modifier and Type | Method and Description |
---|---|
LocalDate |
add(int field,
int amount)
|
boolean |
equals(Object o) |
static LocalDate |
fromDaysSinceEpoch(int daysSinceEpoch)
Builds a new instance from a number of days since January 1st, 1970 GMT.
|
static LocalDate |
fromMillisSinceEpoch(long millisSinceEpoch)
Builds a new instance from a number of milliseconds since January 1st, 1970 GMT.
|
static LocalDate |
fromYearMonthDay(int year,
int month,
int dayOfMonth)
Builds a new instance from a year/month/day specification.
|
int |
getDay()
Returns the day in the month.
|
int |
getDaysSinceEpoch()
Returns the number of days since January 1st, 1970 GMT.
|
long |
getMillisSinceEpoch()
Returns the number of milliseconds since January 1st, 1970 GMT.
|
int |
getMonth()
Returns the month.
|
int |
getYear()
Returns the year.
|
int |
hashCode() |
String |
toString() |
public static LocalDate fromDaysSinceEpoch(int daysSinceEpoch)
daysSinceEpoch
- the number of days.public static LocalDate fromMillisSinceEpoch(long millisSinceEpoch) throws IllegalArgumentException
millisSinceEpoch
- the number of milliseconds since January 1st, 1970 GMT.IllegalArgumentException
- if the date is not in the range [-5877641-06-23;
5881580-07-11].public static LocalDate fromYearMonthDay(int year, int month, int dayOfMonth)
This method is not lenient, i.e. '2014-12-32' will not be treated as '2015-01-01', but
instead throw an IllegalArgumentException
.
year
- the year in ISO format (see this class's Javadoc
).month
- the month. It is 1-based (e.g. 1 for January).dayOfMonth
- the day of the month.IllegalArgumentException
- if the corresponding date does not exist in the ISO8601
calendar.public int getDaysSinceEpoch()
public long getMillisSinceEpoch()
public int getYear()
public int getMonth()
public int getDay()
public LocalDate add(int field, int amount)
LocalDate
with the specified (signed) amount of time added to (or
subtracted from) the given Calendar
field, based on the calendar's rules.
Note that adding any amount to a field smaller than Calendar.DAY_OF_MONTH
will
remain without effect, as this class does not keep time components.
See Calendar
javadocs for more information.
field
- a Calendar
field to modify.amount
- the amount of date or time to be added to the field.LocalDate
with the specified (signed) amount of time added to (or
subtracted from) the given Calendar
field.IllegalArgumentException
- if the new date is not in the range [-5877641-06-23;
5881580-07-11].Copyright © 2012–2018. All rights reserved.