File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes jsf page shows date one day back Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "jsf page shows date one day back" Watch "jsf page shows date one day back" New topic

jsf page shows date one day back

Joby Chacko

Joined: Feb 22, 2012
Posts: 2
When i show the date in jsf page that is fetched from sql table, i get date which is one date back.
Please reply
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

Welcome to the JavaRanch, Joby!

We always try to reply, although it can take a day or 2 sometimes, since we're volunteers, not people paid to be standing by 24x7.

This is probably a timezone issue. There are 2 different places where time zones can be wrong. One is in the database. Some databases will convert dates that are stored into a preferred timezone which is usually either the local timezone or Universal Time (UTC). The other place where timezones can go wrong is in the datetime converter in JSF. Unless you explicitly say otherwise, the default timezone for a date in JSF will always be UTC.

So, in short, it's likely you're not literally off by a day, just a fraction of a day. When it's 22:50 my local time (EST), it's already 03:50 UTC the next day. Give or take an hour. I never can get it right on the first try.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: jsf page shows date one day back
It's not a secret anymore!