@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 |
Modifier and Type | Method and Description |
---|---|
CalendarDate |
add(CalendarPeriod period) |
CalendarDate |
add(double value,
CalendarPeriod.Field unit) |
int |
compareTo(CalendarDate o) |
boolean |
equals(java.lang.Object o) |
Calendar |
getCalendar() |
int |
getDayOfMonth() |
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 void |
main(java.lang.String[] args) |
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 |
parseISOformatOld(java.lang.String calendarName,
java.lang.String isoDateString) |
static CalendarDate |
parseUdunits(java.lang.String calendarName,
java.lang.String udunits)
Get CalendarDate from udunit date string
|
static CalendarDate |
present()
Get a CalendarDate representing the present moment
|
CalendarDate |
subtract(CalendarPeriod period) |
java.util.Date |
toDate()
Get the equivilent java.util.Date
|
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_SECOND
public static final double MILLISECS_IN_MINUTE
public static final double MILLISECS_IN_HOUR
public static final double MILLISECS_IN_DAY
public static final double MILLISECS_IN_YEAR
public static final double MILLISECS_IN_MONTH
public static CalendarDate present()
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 withDoy(Calendar cal, int year, int doy, int hourOfDay, int minuteOfHour, int secondOfMinute)
public 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 of(Calendar cal, long msecs)
cal
- calendar to use, or null for defaultmsecs
- 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 parseISOformatOld(java.lang.String calendarName, java.lang.String isoDateString)
public 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 stringpublic Calendar getCalendar()
public long getMillis()
public int compareTo(CalendarDate o)
compareTo
in interface java.lang.Comparable<CalendarDate>
public boolean isAfter(CalendarDate o)
public boolean isBefore(CalendarDate o)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getTimeUnits()
public int getHourOfDay()
public int getFieldValue(CalendarPeriod.Field fld)
public int getDayOfMonth()
public CalendarDate add(double value, CalendarPeriod.Field unit)
public CalendarDate add(CalendarPeriod period)
public CalendarDate subtract(CalendarPeriod period)
public CalendarDate truncate(CalendarPeriod.Field fld)
fld
- set to 0 all fields less than this onepublic java.util.Date toDate()
public long getDifferenceInMsecs(CalendarDate o)
o
- other calendar datepublic static void main(java.lang.String[] args)