Example
100000

Date

The jp:outputDate can be used to format dates to various output patterns which are defined in AppSettingsBean. The allows a single place in the whole application to configure date patterns and control them with the attributes

  • withDate (default=true)
  • withMinute (default=false)
  • withSecond (default=false)

Please note that the patterns has to match the datatype of the binding value, e.g. a LocalDate with a time pattern will throw a "Unsupported field: HourOfDay" exception.

The type attribute controls the converter implementation and is responsible to handle the new Java 8 (java.time.*) data types.

  • java.text.SimpleDateFormat : date, time or both
  • java.time.format.DateTimeFormatter : localDate, localTime, localDateTime, offsetTime, offsetDateTime or zonedDateTime

Since the pattern in JEESL is fully controlled via different pattern definitions in AppSettingsBean, it's only required to use

  • type= both (Java 7, needs to explicitly be set)
  • type= localDate (Java 8, default setting)
<p:panel header="Example" styleClass="jeesl-panel">
	<p:panelGrid columns="4" columnClasses="jeeslGrid25,jeeslGrid25,jeeslGrid25,jeeslGrid25">
		<p:outputLabel value=""/>
		<p:outputLabel value="Date"/>
		<p:outputLabel value="LocalDate"/>
		<p:outputLabel value="LocalDateTime"/>
			
		<p:outputLabel value="withDate"/>
		<jp:outputDate value="#{outputDateBean.date}" type="both"/>
		<jp:outputDate value="#{outputDateBean.localDate}"/>
		<jp:outputDate value="#{outputDateBean.localDateTime}"/>
			
		<p:outputLabel value="withDate withMinute"/>
		<jp:outputDate value="#{outputDateBean.date}" withMinute="true" type="both"/>
		<h:outputText value=""/>
		<jp:outputDate value="#{outputDateBean.localDateTime}" withMinute="true"/>
			
		<p:outputLabel value="withDate withSecond"/>
		<jp:outputDate value="#{outputDateBean.date}" withSecond="true" type="both"/>
		<h:outputText value=""/>
		<jp:outputDate value="#{outputDateBean.localDateTime}" withSecond="true" type="localDate"/>
		
		<p:outputLabel value="withMinute"/>
		<jp:outputDate value="#{outputDateBean.date}" withDate="false" withMinute="true" type="both" />
		<h:outputText value=""/>
		<jp:outputDate value="#{outputDateBean.localDateTime}" withDate="false" withMinute="true"/>
			
		<p:outputLabel value="withSecond"/>
		<jp:outputDate value="#{outputDateBean.date}" withDate="false" withSecond="true" type="both"/>
		<h:outputText value=""/>
		<jp:outputDate value="#{outputDateBean.localDateTime}" withDate="false" withSecond="true"/>
	</p:panelGrid>
</p:panel>