-
Available since OmniFaces 3.6
The builtin managed bean #{now}
returns you the
java.time.temporal.Temporal
instance representing the current time in server's default time zone.
The implementation is provided by org.omnifaces.cdi.config.DateProducer.TemporalDate
which is essentially written as a CDI proxy for java.time.ZonedDateTime
because it's a final
class.
Raw Temporal#toString()
value of #{now}
: 2024-11-21T00:26:16.656586-06:00[America/Chicago] - this should represent same format as java.time.ZonedDateTime
Formatted using of:formatDate()
function: 2024-11-21 00:26:16
As java.time.Instant
: 2024-11-21T06:26:16.656586Z - this should represent UTC
Formatted using of:formatDate()
function: 2024-11-21 06:26:16
As java.time.ZonedDateTime
: 2024-11-21T00:26:16.656586-06:00[America/Chicago]
Formatted using of:formatDate()
function: 2024-11-21 00:26:16
As epoch time
: 1732170376656
<p>
Raw <code>Temporal#toString()</code> value of <code>\#{now}</code>: <strong>#{now}</strong> - this should represent same format as <code>java.time.ZonedDateTime</code>
</p>
<p>
Formatted using <code>of:formatDate()</code> function: #{of:formatDate(now, 'yyyy-MM-dd HH:mm:ss')}
</p>
<hr/>
<p>
As <code>java.time.Instant</code>: <strong>#{now.instant}</strong> - this should represent UTC
</p>
<p>
Formatted using <code>of:formatDate()</code> function: #{of:formatDate(now.instant, 'yyyy-MM-dd HH:mm:ss')}
</p>
<hr/>
<p>
As <code>java.time.ZonedDateTime</code>: <strong>#{now.zonedDateTime}</strong>
</p>
<p>
Formatted using <code>of:formatDate()</code> function: #{of:formatDate(now.zonedDateTime, 'yyyy-MM-dd HH:mm:ss')}
</p>
<hr/>
<p>
As <code>epoch time</code>: <strong>#{now.time}</strong>
</p>
<h:form>
<h:commandButton value="Refresh">
<f:ajax render=":demo" />
</h:commandButton>
</h:form>