2

jsf 2 glassfish 4 primefaces 5.1

i am using the f:convertDateTime to convert the way date is shown but its showing the wrong date. when i normally show the date it shows Sat Jan 01 00:00:00 AST 2011

which is correct but its not what i want to show

so i am using <f:convertDateTime dateStyle="short"></f:convertDateTime> but instead of showing 01/01/11 its giving me 31/12/10

i tried using <f:convertDateTime pattern="MM/dd/yyyy"></f:convertDateTime> but that also gives me 12/31/2010 instead of 01/01/2011

<p:column headerText="Installation Date"
    filterBy="#{w.installationDate}"
          filterMatchMode="contains"
          sortBy="#{w.installationDate}">
        <h:outputText value="#{w.installationDate}" >
        <f:convertDateTime pattern="MM/dd/yyyy"></f:convertDateTime>
        </h:outputText>
    </p:column>
yahh
  • 1,175
  • 3
  • 14
  • 41
  • 2
    I think you that is a problem with the timezone. Add the timezone to your output to see which timezone is used by the converter. – Jens Nov 11 '14 at 06:30
  • @jens thanks, showing the timezone it showed GMT, but its weird i tried using earlier didnt work, displaying the timezone after your suggestion showed AST was being set to ASKT. dunno why. set it manually to "Asia/Riyadh" and it worked – yahh Nov 11 '14 at 06:41
  • @yahh, how about doing the following http://stackoverflow.com/a/8029448/617373 – Daniel Nov 11 '14 at 07:48

1 Answers1

5

Try adding this to your web.xml

<context-param>
    <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
    <param-value>true</param-value>
</context-param>
Daniel
  • 36,833
  • 10
  • 119
  • 200