@Immutable public class CalendarDate extends java.lang.Object implements java.lang.Comparable<CalendarDate>
Modifier and Type | Field and Description |
---|---|
static double |
MILLISECS_IN_DAY |
static double |
MILLISECS_IN_HOUR |
static double |
MILLISECS_IN_MINUTE |
static double |
MILLISECS_IN_MONTH |
static double |
MILLISECS_IN_SECOND |
static double |
MILLISECS_IN_YEAR |
static CalendarDate |
UNKNOWN |
Modifier and Type | Method and Description |
---|---|
CalendarDate |
add(CalendarPeriod period) |
int |
compareTo(CalendarDate o) |
boolean |
equals(java.lang.Object o) |
Calendar |
getCalendar() |
int |
getDayOfMonth() |
long |
getDifference(CalendarDate o,
CalendarPeriod.Field fld)
Get difference between two calendar dates in given Field units
|
long |
getDifferenceInMsecs(CalendarDate o)
Get difference between two calendar dates in millisecs
|
int |
getFieldValue(CalendarPeriod.Field fld) |
int |
getHourOfDay()
Get the hour of day (0-23) field for this chronology.
|
long |
getMillis()
Gets the milliseconds of the datetime instant from the Java epoch
of 1970-01-01T00:00:00Z.
|
java.lang.String |
getTimeUnits()
udunits formatting
|
int |
hashCode() |
boolean |
isAfter(CalendarDate o) |
boolean |
isBefore(CalendarDate o) |
static CalendarDate |
of(Calendar cal,
int year,
int monthOfYear,
int dayOfMonth,
int hourOfDay,
int minuteOfHour,
int secondOfMinute)
Get Calendar date from fields.
|
static CalendarDate |
of(Calendar cal,
long msecs)
Create CalendarDate from msecs since epoch
Uses the given Calendar.
|
static CalendarDate |
of(java.util.Date date)
Create CalendarDate from a java.util.Date.
|
static CalendarDate |
of(long msecs)
Create CalendarDate from msecs since epoch
Uses standard Calendar.
|
static CalendarDate |
parseISOformat(java.lang.String calendarName,
java.lang.String isoDateString)
Get CalendarDate from ISO date string
|
static CalendarDate |
parseUdunits(java.lang.String calendarName,
java.lang.String udunits)
Get CalendarDate from udunit date string
|
static CalendarDate |
parseUdunitsOrIso(java.lang.String calendarName,
java.lang.String isoOrUdunits)
Get CalendarDate from ISO date string
|
static CalendarDate |
present()
Get a CalendarDate representing the present moment
|
static CalendarDate |
present(Calendar cal) |
CalendarDate |
subtract(CalendarPeriod period) |
java.util.Date |
toDate()
Get the equivilent java.util.Date
|
java.util.GregorianCalendar |
toGregorianCalendar() |
java.lang.String |
toString()
ISO formatted string
|
CalendarDate |
truncate(CalendarPeriod.Field fld)
truncate the CalendarDate, by zeroing all the fields that are less than the field.
|
static CalendarDate |
withDoy(Calendar cal,
int year,
int doy,
int hourOfDay,
int minuteOfHour,
int secondOfMinute) |
public static final double MILLISECS_IN_DAY
public static final double MILLISECS_IN_HOUR
public static final double MILLISECS_IN_MINUTE
public static final double MILLISECS_IN_MONTH
public static final double MILLISECS_IN_SECOND
public static final double MILLISECS_IN_YEAR
public static final CalendarDate UNKNOWN
public CalendarDate add(CalendarPeriod period)
public int compareTo(CalendarDate o)
compareTo
in interface java.lang.Comparable<CalendarDate>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public Calendar getCalendar()
public int getDayOfMonth()
public long getDifference(CalendarDate o, CalendarPeriod.Field fld)
o
- other calendar datepublic long getDifferenceInMsecs(CalendarDate o)
o
- other calendar datepublic int getFieldValue(CalendarPeriod.Field fld)
public int getHourOfDay()
public long getMillis()
public java.lang.String getTimeUnits()
public int hashCode()
hashCode
in class java.lang.Object
public boolean isAfter(CalendarDate o)
public boolean isBefore(CalendarDate o)
public static CalendarDate of(Calendar cal, int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute)
cal
- calendar to use, or null for defaultyear
- any integermonthOfYear
- 1-12dayOfMonth
- 1-31hourOfDay
- 0-23minuteOfHour
- 0-59secondOfMinute
- 0-59public static CalendarDate of(Calendar cal, long msecs)
cal
- calendar to use, or null for defaultmsecs
- milliseconds from 1970-01-01T00:00:00Zpublic static CalendarDate of(java.util.Date date)
date
- java.util.Datepublic static CalendarDate of(long msecs)
msecs
- milliseconds from 1970-01-01T00:00:00Zpublic static CalendarDate parseISOformat(java.lang.String calendarName, java.lang.String isoDateString)
calendarName
- get Calendar from Calendar.get(calendarName). may be nullisoDateString
- ISO date stringpublic static CalendarDate parseUdunits(java.lang.String calendarName, java.lang.String udunits)
calendarName
- get Calendar from Calendar.get(calendarName). may be nulludunits
- must be value (space) udunits string@Nullable public static CalendarDate parseUdunitsOrIso(java.lang.String calendarName, java.lang.String isoOrUdunits)
calendarName
- get Calendar from Calendar.get(calendarName). may be nullisoOrUdunits
- ISO or udunits date stringpublic static CalendarDate present()
public static CalendarDate present(Calendar cal)
public CalendarDate subtract(CalendarPeriod period)
public java.util.Date toDate()
public java.util.GregorianCalendar toGregorianCalendar()
public java.lang.String toString()
toString
in class java.lang.Object
public CalendarDate truncate(CalendarPeriod.Field fld)
fld
- set to 0 all fields less than this onepublic static CalendarDate withDoy(Calendar cal, int year, int doy, int hourOfDay, int minuteOfHour, int secondOfMinute)