I have a really strange problem about showing dates. And particulary in windows. I dont know why, when i get a Date from a query (Hibernate) it gives me one day less. when the data gets to the server the date is fine but when it gets to the client it gives one day less. For example: in the server the date is Fri Sep 24 00:00:00 1982 but when it gets to the client is Thu Sep 23 23:00:00 1982. As you can see its one difference day.
Ah and i almost forget to mention it happens on windows (Seven) as its TimeZone its UTC instead of GMT. Me and my colegues use Linux and there is no problem with it.
Is there any workaround about this?
Thanks in advance!
It’s not giving you a value a day earlier. It’s giving you a value an hour earlier (midnight on September 24th vs 11pm on September 23rd).
That’s almost certainly a time zone issue, which is almost certainly just a reflection of how you’re formatting your dates. If you use
SimpleDateFormatter, just set theTimeZoneappropriately (your actual requirements will determine which zone that is) and you should get the same results.As an aside, in general I’d recommend using Joda Time as far as possible when it comes to date/time work in Java – it’s a much cleaner API than
DateandCalendar.