I’ve got a spring webapp that takes in dates on the front end. Just dates, no times. I then store these dates in java Date objects and they end up on the mysql database in a Date object. Initially I had problems with the dates not aligning between the DB and the Front end. A date would show 12-15-2011 in the DB and display as 12-14-2011 on the Front end. I somehow managed to fix it though and sync it up (I think I stopped it from formatting with the time aspect).
Anyway, now that I’m moving the webapp to my server (which is apparently in GMT while my development box is in EDT) the problem has occurred again. I enter a date into the front end as 12-15-2011 and it propogates to the database and is stored as 12-15-2011. Great. But then when I display the object later, it’s showing up as 12-14-2011. I’m guessing this has something to do with my machine being EDT and the server being GMT but how do I prevent this? I just want the date stored, no times. Do I have to stop using Date objects and just stick with strings? Any help would be greatly appreciated.
Java doesn’t have a concept of “Just Date, no Time” (JodaTime does, plain Java doesn’t). So when you enter a date without time, the time is set to 00:00:00.
You should try to figure out how to set your server’s time zone to yours instead.