Class LocalDate
- java.lang.Object
-
- org.apache.cassandra.cql3.functions.types.LocalDate
-
public final class LocalDate extends java.lang.ObjectA date with no time components, no time zone, in the ISO 8601 calendar.Note that ISO 8601 has a number of differences with the default gregorian calendar used in Java:
- it uses a proleptic gregorian calendar, meaning that it's gregorian indefinitely back in the past (there is no gregorian change);
- there is a year 0.
This class implements these differences, so that year/month/day fields match exactly the ones in CQL string literals.
- Since:
- 2.2
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalDateadd(int field, int amount)Return a newLocalDatewith the specified (signed) amount of time added to (or subtracted from) the givenCalendarfield, based on the calendar's rules.booleanequals(java.lang.Object o)static LocalDatefromDaysSinceEpoch(int daysSinceEpoch)Builds a new instance from a number of days since January 1st, 1970 GMT.static LocalDatefromMillisSinceEpoch(long millisSinceEpoch)Builds a new instance from a number of milliseconds since January 1st, 1970 GMT.intgetDay()Returns the day in the month.intgetDaysSinceEpoch()Returns the number of days since January 1st, 1970 GMT.intgetMonth()Returns the month.intgetYear()Returns the year.inthashCode()java.lang.StringtoString()
-
-
-
Method Detail
-
fromDaysSinceEpoch
public static LocalDate fromDaysSinceEpoch(int daysSinceEpoch)
Builds a new instance from a number of days since January 1st, 1970 GMT.- Parameters:
daysSinceEpoch- the number of days.- Returns:
- the new instance.
-
fromMillisSinceEpoch
public static LocalDate fromMillisSinceEpoch(long millisSinceEpoch) throws java.lang.IllegalArgumentException
Builds a new instance from a number of milliseconds since January 1st, 1970 GMT. Note that if the given number does not correspond to a whole number of days, it will be rounded towards 0.- Parameters:
millisSinceEpoch- the number of milliseconds since January 1st, 1970 GMT.- Returns:
- the new instance.
- Throws:
java.lang.IllegalArgumentException- if the date is not in the range [-5877641-06-23; 5881580-07-11].
-
getDaysSinceEpoch
public int getDaysSinceEpoch()
Returns the number of days since January 1st, 1970 GMT.- Returns:
- the number of days.
-
getYear
public int getYear()
Returns the year.- Returns:
- the year.
-
getMonth
public int getMonth()
Returns the month.- Returns:
- the month. It is 1-based, e.g. 1 for January.
-
getDay
public int getDay()
Returns the day in the month.- Returns:
- the day in the month.
-
add
public LocalDate add(int field, int amount)
Return a newLocalDatewith the specified (signed) amount of time added to (or subtracted from) the givenCalendarfield, based on the calendar's rules.Note that adding any amount to a field smaller than
Calendar.DAY_OF_MONTHwill remain without effect, as this class does not keep time components.See
Calendarjavadocs for more information.- Parameters:
field- aCalendarfield to modify.amount- the amount of date or time to be added to the field.- Returns:
- a new
LocalDatewith the specified (signed) amount of time added to (or subtracted from) the givenCalendarfield. - Throws:
java.lang.IllegalArgumentException- if the new date is not in the range [-5877641-06-23; 5881580-07-11].
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-