5
<rich:column>
    <f:facet name="header">
          <h:outputText value="Expiry Date"/>
    </f:facet>
    <h:outputText value="#{item.endDate}">

    </h:outputText>
</rich:column>

Using above code, I got the date from database is 2012-09-03 00:00:00.0

Now, I want to set the date pattern to dd-MM-yyyy.

So my required output is 03-09-2012.

But using below code (after setting the pattern)

<rich:column>
     <f:facet name="header">
         <h:outputText value="Expiry Date"/>
     </f:facet>
     <h:outputText value="#{item.endDate}">
          <f:convertDateTime pattern="dd-MM-yyyy"  />
     </h:outputText>
</rich:column>

I am getting the output is 02-09-2012

Whatever date is in database, it shows output less by one day.

In advance thanks.

Xavi López
  • 27,550
  • 11
  • 97
  • 161
pioneer
  • 51
  • 3
  • 1
    possible duplicate of [JSF convertDateTime renders the previous day](http://stackoverflow.com/questions/12351244/jsf-convertdatetime-renders-the-previous-day) – BalusC Dec 13 '12 at 12:12
  • Thank for pointing me. Next time, I'll be careful for this. – pioneer Dec 13 '12 at 12:16

1 Answers1

1

You should add suitable timeZone attribute to convertDateTime component. For an example in my zone

<f:convertDateTime pattern="dd-MM-yyyy" timeZone="Asia/Calcutta" />

Note:

you can use java.util.TimeZone.getDefault().getID() to get your current time zone id.

prageeth
  • 7,159
  • 7
  • 44
  • 72