0

the atribbute on my bean

@Temporal(value = TemporalType.TIMESTAMP)
    private Date data;

The date is correctly saved on database

enter image description here

but in the JSF the date is showing wrong. Days are lost

enter image description here

the JSF code

<p:column>
                            <f:facet name="header">
                                <h:outputText value="Data" />
                            </f:facet>
                            <h:outputText value="#{contadores.dataCalendar.time}" >
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>
                        </p:column>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Krismorte
  • 642
  • 7
  • 24
  • It looks like 2 days difference. – glw Aug 07 '15 at 16:33
  • I'm doing some tests, but I think that I miss something in my JSF – Krismorte Aug 07 '15 at 16:37
  • Sorry @Tiny, this was a test, but the type in bean is util.Date – Krismorte Aug 07 '15 at 16:43
  • You know that convertDateTime uses UTC timezone by default? – glw Aug 07 '15 at 16:48
  • So, I have to change that? – Krismorte Aug 07 '15 at 16:59
  • I Aam totally lost now. Where is the sql Date? And where is it not? Details are important. Debug the sql query if needed etc. It indeed looks 2 days – Kukeltje Aug 07 '15 at 18:47
  • 1
    You look like to have a timezone inconsistency in 2 places. In at least the JSF side, this is the answer: http://stackoverflow.com/questions/12351244/jsf-convertdatetime-renders-the-previous-day If that still doesn't fix the problem (but at least brings the difference to 1 day), then look in JPA/DB side for other timezone fail. You'd better breakdown the question in two. – BalusC Aug 07 '15 at 19:06
  • I edit the web.xml and makes no effect – Krismorte Aug 07 '15 at 21:25
  • so when you persist the date, is the SQL correct, and it is stored correct in the DB? and if so then when you retrieve it, is the SQL correct? and are the dates correct in Java after the JPA call? and then in JSF ? do those basic things and you will see where the problem is ... – Neil Stockton Aug 08 '15 at 02:42
  • [This](http://stackoverflow.com/q/7490954/1391249) is too the same in nature. – Tiny Aug 08 '15 at 06:19

0 Answers0