Skip to main content

ConvertDateTime: one day deleted in view forms

7 replies [Last post]
machibat
Offline
Joined: 2008-09-25
Points: 0

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:

the day viewed is the real myDate value, with one day deleted.

if i use only
or

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.

Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vladperl
Offline
Joined: 2004-08-11
Points: 0

I just found out that my applications included JSF 1.2 library in war.
For some reason programmer in Kiev enabled related check box (JSF 1.2 package) in properties of the projects. I was really sure that we don't use JSF 1.2 because applications using facelets that included in JSF 2.0. So look likes we used two version of JSF in one application and it works :)

By the way maybe it's time to include JSF 2.0 library in Netbeans 6.5

Best Regards,
Vladimir

Ed Burns

>>>>> On Thu, 25 Sep 2008 09:05:23 -0700, Ryan Lubke said:

RL> The problem, I believe, is with the TimeZone. Unless the TimeZone is
RL> explicitly set by the user,
RL> f:convertDateTime will use GMT. I'm sure if you update your
RL> getmyDateAsString() implementation
RL> to set the TimeZone to GMT, you will see similar behavior.

FWIW, we fixed this in JSF 2.0.

Ed

--
| ed.burns@sun.com | office: 408 884 9519 OR x31640
| homepage: | http://ridingthecrest.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

vladperl
Offline
Joined: 2004-08-11
Points: 0

> FWIW, we fixed this in JSF 2.0.

Sorry, but seems you didn't fixed it in JSF 2.0 at least when application using facelets.
After we just switched to facelets the same effect show up - date takes day off :)

This effect appears in JSF 2.0 build 5 and JSF 2.0 build 7.

With regular jsp pages DateTime convertor works correctly.

Using timeZone helped to fix the issue but it's not good to use this kind of work around.

Please resolve the issue as soon as possible.

Thank you,
Vladimir

Ryan Lubke

webtier@javadesktop.org wrote:
>> FWIW, we fixed this in JSF 2.0.
>>
>
> Sorry, but seems you didn't fixed it in JSF 2.0 at least when application using facelets.
> After we just switched to facelets the same effect show up - date takes day off :)
>
> This effect appears in JSF 2.0 build 5 and JSF 2.0 build 7.
>
> With regular jsp pages DateTime convertor works correctly.
>
Strange. The view technology should have *no* impact on how
convertDateTime behaves.
> Using timeZone helped to fix the issue but it's not good to use this kind of work around.
> >
> Please resolve the issue as soon as possible.
>
Did you set the
'javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE'
context init parameter in your web.xml to true?

This is the fix Ed was referring to. Instead of defaulting to GMT, if
this option is enabled,
it will use the container's timezone.

> Thank you,
> Vladimir
> [Message sent by forum member 'vladperl' (vladperl)]
>
> http://forums.java.net/jive/thread.jspa?messageID=320841
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

vladperl
Offline
Joined: 2004-08-11
Points: 0

Hi Ryan,
Thank you for quick response.

> Strange. The view technology should have *no* impact
> on how
> convertDateTime behaves.

Ok, just facts:

We decided to start to use facelets so I asked programmer from Ukraine (Kiev) make all related changes to migrate our applications from JSP to Facelets.
After migration was done I have found the issue already in two applications that I evaluated after getting updates from Kiev.

DataTime field states:
1) initialized date such way that time part of the field is zero.
2) user didn't change the date at all but i getting date with time equal 17:00 GMT-5
and date on day before comparing to date that was defined before.

And interesting thing is that Kiev located on (GMT+2) and I'm located on (GMT-5).

24 - 7 = 17

So I don't understand two things:

1) why time is always show 17:00 (should migration take place in other place than Kiev we would get different time?)
2) what else beside migration to facelets could be reason to issue appears

> Did you set the
> 'javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYS
> TEM_TIMEZONE'
> context init parameter in your web.xml to true?

I didn't know about this parameter and when I put it in place everything started worked as expected.

> This is the fix Ed was referring to. Instead of
> defaulting to GMT, if
> this option is enabled,
> it will use the container's timezone.

It's great option!

Because your suggestion resolved my issue I don't need to know answers on my two questions described above. In fact I just tried to provide more light on this topic.

Best Regards,
Vladimir

Ryan Lubke

webtier@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:
>
>
>

> the day viewed is the real myDate value, with one day deleted.
>
> if i use only
> or
>
> 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@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

machibat
Offline
Joined: 2008-09-25
Points: 0

that's it, you're write.



Thanks a lot.