How to convert a datetime value to UTC (or GMT)
807569Sep 20 2006 — edited Sep 21 2006I have this problem.
The user should provide the following inputs:
- A date time value - i.e: 10 september 2006, 10:40 AM
- The world location to which that value refers - i.e.: Rome/Italy
I need as output, the UTC date time value:
- i.e: 10 september 2006, 8:40 AM
in this case it is two hours before because during summer time, the Italian timezone is GMT+2
And if the user enters:
- A date time value - i.e: 25 december 2006, 10:40 AM
- The world location to which that value refers - i.e.: Rome/Italy
The output should be: (UTC time)
- i.e: 25 december 2006, 9:40 AM
It only only one hour before because during winter, in italy the timezone is GMT+1
In few words I need that Java can do by itself all the calculations about the timezone and daylight saving around different places in the world, so that I can store in my DB the universal UTC time.
Can you suggest me some code or some good URLs?
Thanks in advance