I'm using the API from wunderground.com. I'm having a problem formatting the time like they've done on the homepage. He's an example: 4:58 PM BST on July 13, 2011 (GMT +0100). The time values in the XML document look like this:
Basically, how would I go about formatting the time values from the XML document to make them look like this: 4:58 PM BST on July 13, 2011 (GMT +0100)? The main problem I'm having is with the GMT offset (GMT +100).
They are all the same time value, aren't they? Just represented in three different ways?
If that's the case, I would try taking the <local_epoch> value and creating a Date object from it, using the new Date(long) constructor. Then I would create a suitable SimpleDateFormat object and use that to format the Date you just created.
There are no new questions, but there may be new answers.
Joined: Jul 13, 2011
Hi Paul thanks for the reply. The values are actually different <local_time> is the time of the time zone for the location and <local_time_rfc822> is the GMT offset. for Example if I did a search for Leeds, UK the local time would be BST which is (GMT +0100). If I did a search for Hollywood, FL the local time would be EDT and the GMT offset would be (GMT -0400).
I tried your suggestion using the <local_epoch> value with something like:
Format formatter = new SimpleDateFormat("hh:mm 'on' a z Z");
long timeStamp = 1247590877;
Date date = new Date(timeStamp * 1000);
No matter what location I query it always returns BST +0100.
I need some way to work out the GMT offset for the local time of what ever location I query and format it like; 4:56 PM EDT on July 13, 2011 (GMT -0400).
That's because the time zone of your SimpleDateFormatter is what you said there. If you want the SimpleDateFormatter to display your date in some other time zone, then call its setTimeZone() method with that time zone.
Or perhaps I'm misunderstanding your requirements?