webtier@glassfish.java.net

Re: [webtier] ConvertDateTime: one day deleted in view forms

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Thu, 25 Sep 2008 09:05:23 -0700

webtier_at_javadesktop.org wrote:
> Hye,
> I found an error which i can't resolve.
> In my class, i have one date in a class:
> public Class myClass{
>
> java.util.Date myDate;
>
> public java.util.Date getMyDate()
> {
> return this.myDate;
> }
>
> public String getmyDateAsString() {
> SimpleDateFormat formatAMJ = new SimpleDateFormat("dd/MM/yyyy");
> String oneDate = formatAMJ.format(this.getMyDate());
> return oneDate;
> }
> ...
>
> }
> in my view form, if i use:
> <h:outputText value="#{fmyFormPojo.myEntity.myDate}">
> <f:convertDateTime pattern="dd.MM.yyyy" />
> </h:outputText>
> the day viewed is the real myDate value, with one day deleted.
>
> if i use only
> <h:outputText value="#{fmyFormPojo.myEntity.myDate}"> or
> <h:outputText value="#{fmyFormPojo.myEntity.myDateAsString}">
> the date viewed is the real value of myDate
>
> for example:
> in the Database, myDate is 25/09/2008.
> with the use of convertDateTime, the date is 24/09/2008
> without convertDateTime, the date is : 25 sept. 2008
> with the use of getMyDateAsString methode, the Date value rendered is correct.
>
> Could someone tell me where could be the mistake? i tried Locale, i inverted day and month in convertDateTime call without result.
>
The problem, I believe, is with the TimeZone. Unless the TimeZone is
explicitly set by the user,
f:convertDateTime will use GMT. I'm sure if you update your
getmyDateAsString() implementation
to set the TimeZone to GMT, you will see similar behavior.

To resolve it, explicitly set the TimeZone you need.
> Thanks in advance.
> [Message sent by forum member 'machibat' (machibat)]
>
> http://forums.java.net/jive/thread.jspa?messageID=301562
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net
>
>