my dog learned polymorphism
The moose likes JSF and the fly likes F:convertDateTime display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "F:convertDateTime display " Watch "F:convertDateTime display " New topic

F:convertDateTime display

Augustine Chelliah

Joined: Mar 12, 2009
Posts: 28

I have a to be displayed in the JSF page. I'm using t:outputText and f:convertDateTime to display in (MM/dd/yyyy hh:mm:ss a) format. But when the page is rendered, I'm getting the corresponding GMT time instead of the correct one.

For Eg, my date is Feb 9 2009 07:30:29 AM but i get 02/09/2009 12:30:29 PM when the page is rendered. Please help

Thanks & Regards,
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
To start, it returns the date/time of the server machine, not this of the client machine.
You can make use of the 'timeZone' attribute of the f:convertDateTime to control it.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

One of the most irritating things about the f:converDateTime is that it doesn't attempt to use the client's locale to adjust the displayed date/time or even offer an option to do so. If you omit a timezone, GMT will be used. Not the server's time, unless you're in the GMT timezone or haven't localized the server.

My servers run a GMT hardware clock, but their OS native timezone is EST/EDT. Which is what's so frustrating, since the default convertDateTime will render times and dates in GMT even though that's not the native locale of either the clients or the servers.

The timeZone attribute will make that adjustment, but requires that the server code explicitly provide the appropriate local info, which is bad enough when the users are all in one timezone, and worse when users are scattered around the world.

I hope someday that they'll fix that.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: F:convertDateTime display
It's not a secret anymore!