Package org.omnifaces.cdi.config
Class DateProducer.TemporalDate
- java.lang.Object
-
- org.omnifaces.cdi.config.DateProducer.TemporalDate
-
- All Implemented Interfaces:
Serializable,Comparable<DateProducer.TemporalDate>,Temporal,TemporalAccessor
- Enclosing class:
- DateProducer
public static class DateProducer.TemporalDate extends Object implements Temporal, Comparable<DateProducer.TemporalDate>, Serializable
ZonedDateTimeis a final class, hence this proxy for CDI. Plus, it also offers a fallback for existing EL expressions relying onDate.getTime()such as#{now.time}so that they continue working after migration fromDatetoTemporalin OmniFaces 4.0.- Since:
- 4.0
- Author:
- Bauke Scholtz
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TemporalDate()Constructs a new proxyable temporal date which is initialized withZonedDateTime.now().TemporalDate(ZonedDateTime zonedDateTime)Constructs a new proxyable temporal date which is initialized with givenZonedDateTime.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(DateProducer.TemporalDate other)booleanequals(Object other)ReturnsZonedDateTime.equals(Object)InstantgetInstant()Convenience method to return this temporal date asInstantatZoneOffset.UTC.longgetLong(TemporalField field)longgetTime()Has the same signature asDate.getTime().ZonedDateTimegetZonedDateTime()Convenience method to return this temporal date asZonedDateTimeatZoneId.systemDefault().inthashCode()ReturnsZonedDateTime.hashCode()booleanisSupported(TemporalField field)booleanisSupported(TemporalUnit unit)Temporalplus(long amountToAdd, TemporalUnit unit)StringtoString()ReturnsZonedDateTime.toString().longuntil(Temporal endExclusive, TemporalUnit unit)Temporalwith(TemporalField field, long newValue)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.time.temporal.TemporalAccessor
get, query, range
-
-
-
-
Constructor Detail
-
TemporalDate
public TemporalDate()
Constructs a new proxyable temporal date which is initialized withZonedDateTime.now().
-
TemporalDate
public TemporalDate(ZonedDateTime zonedDateTime)
Constructs a new proxyable temporal date which is initialized with givenZonedDateTime.- Parameters:
zonedDateTime- ZonedDateTime to initialize with.- Throws:
NullPointerException- when given ZonedDateTime isnull.
-
-
Method Detail
-
getZonedDateTime
public ZonedDateTime getZonedDateTime()
Convenience method to return this temporal date asZonedDateTimeatZoneId.systemDefault().- Returns:
- This as
ZonedDateTimeatZoneId.systemDefault().
-
getInstant
public Instant getInstant()
Convenience method to return this temporal date asInstantatZoneOffset.UTC.- Returns:
- This as
InstantatZoneOffset.UTC.
-
getTime
public long getTime()
Has the same signature asDate.getTime(). This ensures that#{now.time}and#{startup.time}keep working.- Returns:
- The number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this temporal date.
-
compareTo
public int compareTo(DateProducer.TemporalDate other)
- Specified by:
compareToin interfaceComparable<DateProducer.TemporalDate>
-
equals
public boolean equals(Object other)
ReturnsZonedDateTime.equals(Object)
-
hashCode
public int hashCode()
ReturnsZonedDateTime.hashCode()
-
toString
public String toString()
ReturnsZonedDateTime.toString().
-
isSupported
public boolean isSupported(TemporalField field)
- Specified by:
isSupportedin interfaceTemporalAccessor
-
getLong
public long getLong(TemporalField field)
- Specified by:
getLongin interfaceTemporalAccessor
-
isSupported
public boolean isSupported(TemporalUnit unit)
- Specified by:
isSupportedin interfaceTemporal
-
with
public Temporal with(TemporalField field, long newValue)
-
plus
public Temporal plus(long amountToAdd, TemporalUnit unit)
-
until
public long until(Temporal endExclusive, TemporalUnit unit)
-
-