views:

14

answers:

1

Whats the best way to accomplish changing the timezone of an app? The way I see it the following must occur:

  1. Server TZ is changed by sys admin
  2. mysql must be restarted.
  3. every time based column in the database must have all values updated, using convert_tz or equivalent. So either a mysql script must be written or a grails script that loads every row for each class, updating all the time fields.

Obviously the server should be taken down while this is happening, and backups must be in place incase of an error.

Is there a better/easier way to do this?

A: 

Java does not use time zones when using Dates; it stores everything as UTC and only uses time zones when displaying dates. see the following link for a discussion of java date/time. http://www.odi.ch/prog/design/datetime.php If your using the Date, Time, or DateTime column types in MySQL time zone does not matter, if you’re using the TIMESTAMP column type time zones may matter since the TIMESTAMP is stored as a UTC but has conversion done when both retrieving and storing the values. For a discussion of MySQL time zone behavior see http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html If you’re worried about synchronizing objects across multiple servers in different time zones things get more complicated, see the following thread for a discussion of this. http://www.pubbs.net/201006/grails/2500-grails-user-how-to-get-gorm-to-store-dates-as-timestamp-in-utc-by-default-without-a-custom-hibernate-mapping-or-joda-time-plu.html

Jared