This content has been marked as final.
Show 3 replies
-
1. Re: Problem retrieving dates from database
Elias Ross Nov 17, 2007 1:55 AM (in response to Olivier Thierry)You can do something like this:
public void setDateDebut(java.util.Date value) { this.dateDebut = new java.util.Date(value.getTime()); }
-
2. Re: Problem retrieving dates from database
Olivier Thierry Nov 19, 2007 4:21 AM (in response to Olivier Thierry)Thanks, it works.
Anyway I thought this was what caused my formatting problems, but I still have them ...
For example, I have a java.util.Date variable which contains "Thu Nov 15 00:00:00 CET 2007" value.
If I format it with SimpleDateFormat :SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); System.out.println(sdf.format(membreUniteOrganisation.getDateDebut()));
It prints "15/11/2007" which is right.
But if I format it with <f:convertDateTime> with datePattern as "dd/MM/yyyy" :<h:outputText value="#{membre.dateDebut}"> <f:convertDateTime pattern="#{messages['datePattern']}" /> </h:outputText>
It prints "14 nov. 2007" which is wrong of course !
Any idea why ? -
3. Re: Problem retrieving dates from database
Olivier Thierry Nov 19, 2007 5:02 AM (in response to Olivier Thierry)I found my problem. You just have to know that <f:convertDateTime> works by default with UTC time and not with the date variable timezone, which is not the case with java.util.SimpleDateFormat. So you have to explicitely set the timezone attribute for <f:convertDateTime>
Something like that :<h:outputText value="#{membre.dateDebut}"> <f:convertDateTime pattern="#{messages['datePattern']}" timeZone="GMT+1" /> </h:outputText>