Sorry? I'm missing a time zone in the string I'm trying to parse?
That string is actually dynamic, I just wrote it has hardcoded for clarity. In the dynamic string, no time zone is given. I thought if no time zone was present, the date parser would use the local time zone?
The "z" at the end of the format string means there's going to be a timezone at the end of the date string.
And what made you think that it would default to the local timezone? Can you point to where it says that in the API documentation? Because if it doesn't say that, then that isn't the case.
Johann Dobbins wrote:I need to parse a date string into the following format: 20 Jun 1982 12:00:00 GMT.
Dates have no formatting of their own, so you would need two DateFormats for this: one for parsing, one for formatting. Although if you know the Date to format you can also use java.util.Calendar to create the Date:
Johann Dobbins wrote:I need to parse a date string into the following format: 20 Jun 1982 12:00:00 GMT.
Dates have no formatting of their own, so you would need two DateFormats for this: one for parsing, one for formatting. Although if you know the Date to format you can also use java.util.Calendar to create the Date:
Johann Dobbins wrote:I need to parse a date string into the following format: 20 Jun 1982 12:00:00 GMT.
Parsing means converting a String to a Date. The opposite, converting a Date to a String, is formatting.
So you can't "parse a date string into format X" - you parse a String with a format X into a Date object, or you format a Date object into a String with format X.
Johann Dobbins wrote:I need to parse a date string into the following format: 20 Jun 1982 12:00:00 GMT.
Parsing means converting a String to a Date. The opposite, converting a Date to a String, is formatting.
So you can't "parse a date string into format X" - you parse a String with a format X into a Date object, or you format a Date object into a String with format X.
Thank you for your help.
I hired a bunch of ninjas. The fridge is empty, but I can't find them to tell them the mission.