Hi
Thanks for your comment. I spent last night trying to read up about this and i think i understand it a little bit now.
What i would like to do is to convert a supplied date which is on a specific time zone to UTC or from a date that is in UTC to a specific timezone.
Note: The date will not come from the system but will be provided as a
String parameter
Here is how i tried to achieve the above
- To convert from local timezone to UTC
- To Convert from UTC to Local Timezone
I tested the above with the following
test date
And here was the output
[code]
convertLocalTimeToUTC: LON: The Date in the local time zone 03-11-2008 11:00:00 GMT(+0000)
convertLocalTimeToUTC: LON: The Date in the UTC time zone 03-11-2008 11:00:00 UTC(+0000)
convertLocalTimeToUTC: NBI: The Date in the local time zone 03-11-2008 11:00:00 EAT(+0300)
convertLocalTimeToUTC: NBI: The Date in the UTC time zone 03-11-2008 08:00:00 UTC(+0000)
convertLocalTimeToUTC: BRS: The Date in the local time zone 03-11-2008 11:00:00 CET(+0100)
convertLocalTimeToUTC: BRS: The Date in the UTC time zone 03-11-2008 10:00:00 UTC(+0000)
convertLocalTimeToUTC: MNT: The Date in the local time zone 03-11-2008 11:00:00 EST(-0500)
convertLocalTimeToUTC: MNT: The Date in the UTC time zone 03-11-2008 16:00:00 UTC(+0000)
convertLocalTimeToUTC: LAS: The Date in the local time zone 03-11-2008 11:00:00 PST(-0800)
convertLocalTimeToUTC: LAS: The Date in the UTC time zone 03-11-2008 19:00:00 UTC(+0000)
convertUTCtoLocalTime LON: The Date in the UTC time zone(UTC) 03-11-2008 11:00:00 GMT(+0000)
convertUTCtoLocalTime: LON: The Date in the LocalTime Zone time zone 03-11-2008 11:00:00 GMT(+0000)
convertUTCtoLocalTime NBI: The Date in the UTC time zone(UTC) 03-11-2008 11:00:00 GMT(+0000)
convertUTCtoLocalTime: NBI: The Date in the LocalTime Zone time zone 03-11-2008 14:00:00 EAT(+0300)
convertUTCtoLocalTime BRS: The Date in the UTC time zone(UTC) 03-11-2008 11:00:00 GMT(+0000)
convertUTCtoLocalTime: BRS: The Date in the LocalTime Zone time zone 03-11-2008 12:00:00 CET(+0100)
convertUTCtoLocalTime MNT: The Date in the UTC time zone(UTC) 03-11-2008 11:00:00 GMT(+0000)
convertUTCtoLocalTime: MNT: The Date in the LocalTime Zone time zone 03-11-2008 06:00:00 EST(-0500)
convertUTCtoLocalTime LAS: The Date in the UTC time zone(UTC) 03-11-2008 11:00:00 GMT(+0000)
convertUTCtoLocalTime: LAS: The Date in the LocalTime Zone time zone 03-11-2008 03:00:00 PST(-0800)
[code]
Now as this is my first time playing with dates im not sure if this is correct. I think it is but im not sure if its the correct way of doing it. Is there another standard way of doing this? Do you think that there might be situations where this wont work? And most importantly, what will happen when the clocks move forward or back? Does java recognise this for each city and adjust accordingly?
Thanks