Announcement Announcement Module
No announcement yet.
Timezone handling in spring/hibernate application Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Timezone handling in spring/hibernate application

    I would like to find out the best practise for making the application timezone aware. The application for now needs a configurable default timezone but in the future this will need to be based on the customer location (possibly session based or page/entity based).

    The application uses Spring 3.1.0.RELEASE (mvc, core), Hibernate 3.6.0 Final (using spring-data repositories)

    The dates are stored as timestamp. I just found out that the server will be outside the country. The server clock is in UTC. I have some questions regarding handling timezones properly.

    1. Is there recommended way to set the default application timezone? and the user's session timezone?

    2. Java Date is supposed to be UTC but how do I do the conversion. I have a jquery date picker that binds to a Date field. On my local machine (macbook air .. get one its amazing) the local timezone is sydney/australia but it is not being applied. The Date field just has the value from the Date picker. Should I bind a Calendar object instead or can I specify a timezone in the binding somehow?

    3. I have seen some posts such as this one regarding setting the timezone on the database connection to do the conversion on the read. This seems to set it on the db connection .. Is this the recommended approach? Would this approach also work with connection pools?

    It seems that this is quite a commonly asked question but not too many good answers on the net. Would some of the spring gurus answer this for all of us?
    Last edited by lilolme; May 1st, 2012, 08:32 PM. Reason: clarification