Name: bsC130419 Date: 05/18/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
Timezone with 1/2 hour offset parsed incorrectly, unless TZ prefixed by GMT :-
In the 'Test2' example below, the timezone of +9:30 is incorrectly parsed by
the SimpleDateFormat pattern as +9:00 (the 1/2 hour offset is dropped).
Only by specifying the zone as GMT+9:30 does the parser correctly interpret the
date.
Test 1 : 2001/05/15T17:15:55.333 +9:00 Out 1 : 2001/05/15T04:15:55.333 Eastern
Daylight Time
Test 2 : 2001/05/15T17:15:55.333 +9:30 Out 2 : 2001/05/15T04:15:55.333 Eastern
Daylight Time
Test 3 : 2001/05/15T17:15:55.333 GMT+9:30 Out 3 : 2001/05/15T03:45:55.333
Eastern Daylight Time
import java.text.*;
import java.util.*;
class Test {
public static void main(String args[]) {
String test1 = "2001/05/15T17:15:55.333 +9:00";
String test2 = "2001/05/15T17:15:55.333 +9:30";
String test3 = "2001/05/15T17:15:55.333 GMT+9:30";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd'T'HH:mm:ss.SSS
zzzz");
try {
System.out.println(" Test 1 : "+test1+" Out 1 : "+(sdf.format
(sdf.parse(test1))));
System.out.println(" Test 2 : "+test2+" Out 2 : "+(sdf.format
(sdf.parse(test2))));
System.out.println(" Test 3 : "+test3+" Out 3 : "+(sdf.format
(sdf.parse(test3))));
} catch(ParseException e) {
System.out.println("ParseException ");
}
}
}
(Review ID: 124639)
======================================================================
- duplicates
-
JDK-4212077 API: SimpleDateFormat.parse throws StringIndexOutOfBoundException w/ GMT+0100
-
- Closed
-