Re: DateFormat problem
From: Jonas Kongslund (dont_at_mail.me.at.all)
Date: 11/04/03
- Next message: Chuck: "rotating a polygon?"
- Previous message: Kevin Wright: "Alternative to Visual Cafe."
- In reply to: David Rasmussen: "Re: DateFormat problem"
- Next in thread: David Rasmussen: "Re: DateFormat problem"
- Reply: David Rasmussen: "Re: DateFormat problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 04 Nov 2003 16:29:06 +0100
David Rasmussen wrote:
> Jonas Kongslund wrote:
>>
>> The pattern looks fine. Your example is wrong: replace CET with GMT.
>>
>
> System.out.println(
> new SimpleDateFormat(
> "EEE, dd MMM yyyy HH:mm:ss z"
> ).parse(
> "Sun, 12 Oct 2003 16:25:01 GMT"
> )
> );
>
> Gives the same ParseException.
Works for me. I'm using JDK 1.4.1_02.
> Well, I am not exactly implementing HTTP. I just used it as an example.
> I want to be able to parse the original string that I posted. Surely
> Java can parse dates that are in CET (or any other time zone)?
I just found out that it depends on your JDK version. SimpleDateFormat uses
java.util.TimeZone, which may or may not support other three-letter time
zone IDs than "GMT". The javadoc for TimeZone bundled with JDK 1.4.1 states
the following:
<quote>
Three-letter time zone IDs
For compatibility with JDK 1.1.x, some other three-letter time zone IDs
(such as "PST", "CTT", "AST") are also supported. However, their use is
deprecated because the same abbreviation is often used for multiple time
zones (for example, "CST" could be U.S. "Central Standard Time" and "China
Standard Time"), and the Java platform can then only recognize one of them.
</quote>
Try running this code:
String[] ids = TimeZone.getAvailableIDs();
for (int i = 0; i < ids.length; i++) {
System.out.println(ids[i]);
}
-- Jonas Kongslund
- Next message: Chuck: "rotating a polygon?"
- Previous message: Kevin Wright: "Alternative to Visual Cafe."
- In reply to: David Rasmussen: "Re: DateFormat problem"
- Next in thread: David Rasmussen: "Re: DateFormat problem"
- Reply: David Rasmussen: "Re: DateFormat problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|