Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jsf datetimeconverter showing date one day before

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>
like image 511
yahh Avatar asked Dec 04 '25 17:12

yahh


1 Answers

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>
like image 144
Daniel Avatar answered Dec 06 '25 11:12

Daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!