The JSF specification requires that f:convertDateTime:
* interpret the input Date object as being in UTC (this is part of the
spec for java.util.Date)
* map the timezone of the input Date object using the specified
timeZone (or UTC if none specified)
I suspect the problem with your program is in fact that when you load
dates from the database they are being treated as belonging to some
specific timezone, and are being adjusted to UTC (which would be
correct, as java.util.Date should hold a UTC value). Then the
f:convertDateTime has no timezone set, so is writing them out *without*
adjusting them in any way.
The myfaces sandbox project provides an "s:convertDateTime" that always
assumes that timeZone is the localhost timezone rather than UTC. That's
not really very nice, as it only works when a server is limited to users
from one timezone. But if that is your scenario then it might save a
little bit of typing. A very little bit.
Regards,
Simon
Guy Bashan schrieb:
> Thanks for your replay,
> That is exactly my problem, I don't want to use timeZone, and I don't want
> java to do any shifting on the time using a default timeZone.
> For example, I have a date in db: 1/1/2008 00:00.
> I want the date to be shown exactly like that, without any timeZone
> shifting.
> I do want that the date will be formatted according to the given locale.
>
> Something like this:
> <f:convertDateTime locale="#{appBean.userLanguageLocale}" type="both"
> timeZone="NONE" />
>
> Is it possible? Or will I have to use java code for that?
>
> Thanks,
> Guy.
>
> -----Original Message-----
> From: Christopher Cudennec [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 03, 2008 12:05 AM
> To: MyFaces Discussion
> Subject: Re: [Faces][Core]
>
> Hi Guy,
>
> did you have look at Sun's documentation? You can pass a time zone to
> the converter. See
> http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/tlddocs/f/convertDate
> Time.html
> for more information.
>
> Cheers,
>
> Christopher
>
> Guy Bashan schrieb:
>
>> Hi,
>>
>>
>>
>> Is it possible not to make any time zone shifting in <f:convertDateTime>.
>>
>> For example:
>>
>> <h:outputText
>> value="#{cmp_summary.cmpCampaign.cmpDeliveryLimits.startDate}">
>>
>> <f:convertDateTime locale="#{appBean.userLanguageLocale}"
>> type="both" />
>>
>> </h:outputText>
>>
>>
>>
>> I want to format the date according to the locale, but that no time
>>
> shifting
>
>> will take place, since the exact value in db should be shown on screen.
>>
>>
>