public final class CalendarDate extends Object implements Temporal, Comparable<CalendarDate>
Originally, long before Java 8 and its new Date and Time API, this class was designed to provide an immutable complement to the existing Date and Calendar classes and to have easy/direct access to the underlying epoch millisecond value.
In terms of the newer API it most closely corresponds to an Instant, but does not have its nanosecond granularity. At one point the plan was to remove and replace this class with Instant, but working with a single long as an "instant" representation is very practical and efficient.
It has been retrofitted to implement the Temporal interface.
CalendarDateDuration
,
CalendarDateUnit
Modifier and Type | Class and Description |
---|---|
static interface |
CalendarDate.Resolution
|
Modifier and Type | Field and Description |
---|---|
long |
millis
An "instant" with ms precision.
|
Constructor and Description |
---|
CalendarDate() |
CalendarDate(Calendar calendar) |
CalendarDate(Date date) |
CalendarDate(long timeInMillis) |
CalendarDate(String sqlString) |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
get, query, range
public final long millis
Instant.toEpochMilli()
and/or
System.currentTimeMillis()
.public CalendarDate()
public CalendarDate(Calendar calendar)
public CalendarDate(Date date)
public CalendarDate(long timeInMillis)
public CalendarDate(String sqlString) throws RecoverableCondition
sqlString
- The String to parseRecoverableCondition
- When(if parsing the String failspublic static CalendarDate from(TemporalAccessor temporal)
public static CalendarDate make(Calendar calendar, CalendarDate.Resolution resolution)
public static CalendarDate make(CalendarDate.Resolution resolution)
public static CalendarDate make(Date date, CalendarDate.Resolution resolution)
public static CalendarDate make(long timeInMIllis, CalendarDate.Resolution resolution)
public static CalendarDate now()
public static LocalDateTime toLocalDateTime(Instant instant, ZoneId zone)
public static OffsetDateTime toOffsetDateTime(Instant instant, ZoneId zone)
public static OffsetDateTime toOffsetDateTime(Instant instant, ZoneId zone, Instant zoneToOffsetConversionInstant)
public static OffsetDateTime toOffsetDateTime(Instant instant, ZoneOffset offset)
public static ZonedDateTime toZonedDateTime(Instant instant, ZoneId zone)
public static CalendarDate valueOf(Instant instant)
public static CalendarDate valueOf(OffsetDateTime offsetDateTime)
public static CalendarDate valueOf(ZonedDateTime zonedDateTime)
public <T extends Temporal> T adjustInto(T temporal)
public int compareTo(CalendarDate ref)
compareTo
in interface Comparable<CalendarDate>
public CalendarDate filter(CalendarDateUnit resolution)
public long getLong(TemporalField field)
getLong
in interface TemporalAccessor
public boolean isSupported(TemporalField field)
isSupported
in interface TemporalAccessor
public boolean isSupported(TemporalUnit unit)
isSupported
in interface Temporal
public Temporal plus(long amountToAdd, TemporalUnit unit)
public CalendarDate step(CalendarDateDuration aStepDuration)
public CalendarDate step(CalendarDateUnit aStepUnit)
public CalendarDate step(int aStepCount, CalendarDateUnit aStepUnit)
public Calendar toCalendar()
public Date toDate()
public Instant toInstant()
public LocalDate toLocalDate(ZoneOffset offset)
public LocalDateTime toLocalDateTime(ZoneOffset offset)
public LocalTime toLocalTime(ZoneOffset offset)
public OffsetDateTime toOffsetDateTime(ZoneOffset offset)
@Deprecated public Date toSqlDate()
@Deprecated public Date toSqlTime()
@Deprecated public Date toSqlTimestamp()
public ZonedDateTime toZonedDateTime(ZoneOffset offset)
public long until(Temporal endExclusive, TemporalUnit unit)
public CalendarDate with(TemporalAdjuster adjuster)
public CalendarDate with(TemporalField field, long newValue)
Copyright © 2019 Optimatika. All rights reserved.