Reputation: 9241
When storing time zone for a given date, is there a particular advantage offered by persisting the time zone's ID string (e.g. Joda's DateTimeZone.getId()
) versus saving the local time offset from UTC (e.g. Joda's DateTimeZone.getOffset()
)?
Although Joda's DateTimeZone and the JDK's TimeZone appear to share ID strings, it seems that saving the offset would be more language agnostic.
Upvotes: 2
Views: 673
Reputation: 11909
Storing with the offset only you will not know about daylight savings etc. Example from the doc: "Using this system, America/Los_Angeles is expressed as UTC-08:00, or UTC-07:00 in the summer"
Upvotes: 1
Reputation: 3634
The answer depends on you're use case. The offset is language agnostic, but might need to be interpreted back to the ID for a user to pick from. Most users don't know what they're offset is. On the other hand, if you're users can be reasonably expected to know their offset, then you don't need to interpret. It's more of a design decision then it is a best practice issue.
Upvotes: 1