@Immutable public class CalendarDate extends Object implements 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) |
CalendarDate |
add(double value,
CalendarPeriod.Field unit)
Deprecated.
use CalendarDate add(CalendarPeriod period)
|
int |
compareTo(CalendarDate o) |
boolean |
equals(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.
|
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(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(String calendarName,
String isoDateString)
Get CalendarDate from ISO date string
|
static CalendarDate |
parseUdunits(String calendarName,
String udunits)
Get CalendarDate from udunit date string
|
static CalendarDate |
parseUdunitsOrIso(String calendarName,
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) |
Date |
toDate()
Get the equivilent java.util.Date
|
GregorianCalendar |
toGregorianCalendar() |
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 CalendarDate UNKNOWN
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 present(Calendar cal)
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(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:00Z@Nullable public static CalendarDate parseUdunitsOrIso(String calendarName, String isoOrUdunits)
calendarName
- get Calendar from Calendar.get(calendarName). may be nullisoOrUdunits
- ISO or udunits date stringpublic static CalendarDate parseISOformat(String calendarName, String isoDateString)
calendarName
- get Calendar from Calendar.get(calendarName). may be nullisoDateString
- ISO date stringpublic static CalendarDate parseUdunits(String calendarName, 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 Comparable<CalendarDate>
public boolean isAfter(CalendarDate o)
public boolean isBefore(CalendarDate o)
public String toString()
public 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 Date toDate()
public long getDifferenceInMsecs(CalendarDate o)
o
- other calendar datepublic long getDifference(CalendarDate o, CalendarPeriod.Field fld)
o
- other calendar datepublic GregorianCalendar toGregorianCalendar()