java.lang.Object
org.omnifaces.cdi.config.DateProducer
Producer for #{startup} and #{now}.
Since 4.0 it produces by default an instance of Temporal whereas it previously produced an instance of
Date.
Historical note: since 1.0 these were registered as beans in faces-config.xml. Since 3.6 these were migrated to CDI producers, because the CDI implementation being used may emit warnings on them not being proxyable.
Usage
- You can reference the application startup time as
Temporalvia#{startup}in EL. - You can reference the current time as
Temporalvia#{now}in EL. - They have a
DateProducer.TemporalDate.getTime()method which allows you to obtain the epoch time via#{startup.time}and#{now.time}in EL. - They have a
DateProducer.TemporalDate.getInstant()method which allows you to convert them toInstantatZoneOffset.UTCvia#{startup.instant}and#{now.instant}in EL. - They have a
DateProducer.TemporalDate.getZonedDateTime()method which allows you to convert them toZonedDateTimeatZoneId.systemDefault()via#{startup.zonedDateTime}and#{now.zonedDateTime}in EL. - Since 4.7, they also have
DateProducer.TemporalDate.getLocalDateTime(),DateProducer.TemporalDate.getLocalDate()andDateProducer.TemporalDate.getLocalTime()methods which allows you to convert them toLocalDateTime,LocalDateandLocalTimevia#{startup.localDateTime},#{now.localDateTime}, etc in EL. - They are injectable in CDI beans via e.g.
@Inject @Named private Temporal startup;.
- Since:
- 3.6
- Author:
- Bauke Scholtz
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classZonedDateTimeis a final class, hence this proxy for CDI. -
Constructor Summary
Constructors -
Method Summary