- java.lang.Object
-
- org.omnifaces.cdi.config.DateProducer
-
@Dependent public class DateProducer extends Object
Producer for
#{startup}and#{now}.Since 4.0 it produces by default an instance of
Temporalwhereas it previously produced an instance ofDate.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. - They are injectable in CDI beans via e.g.
@Inject @Named private Temporal startup;.
- Since:
- 3.6
- Author:
- Bauke Scholtz
- You can reference the application startup time as
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDateProducer.TemporalDateZonedDateTimeis a final class, hence this proxy for CDI.
-
Constructor Summary
Constructors Constructor Description DateProducer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DateProducer.TemporalDategetNow()This makes an instance ofTemporalas current datetime available by#{now}.DateProducer.TemporalDategetStartup()This makes an instance ofTemporalas startup datetime available by#{startup}.
-
-
-
Method Detail
-
getStartup
@Produces @Named @ApplicationScoped @Eager public DateProducer.TemporalDate getStartup()
This makes an instance ofTemporalas startup datetime available by#{startup}.- Returns:
- Startup datetime.
-
getNow
@Produces @Named @RequestScoped public DateProducer.TemporalDate getNow()
This makes an instance ofTemporalas current datetime available by#{now}.- Returns:
- Current datetime.
-
-