-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.2.0
-
sparc
-
solaris_2.5.1
Name: tb29552 Date: 10/09/98
/*
The following code:
sdf = new SimpleDateFormat("MM/dd/yyyy");
sdf.setLenient(false);
java.util.Date d = sdf.parse("10/28/98");
will NOT throw a ParseException. Furthermore,
d.toString() will print as:
Sat Oct 28 00:00:00 PDT 0098
And yet:
sdf = new SimpleDateFormat("MM/dd/yyyy");
sdf.setLenient(false);
java.util.Date d = sdf.parse("10/28/00");
throws a ParseException as expected.
*/
import java.text.*;
import java.util.*;
class DateParseTest {
public static void outputMessage(){
System.out.println("java.version = " +
System.getProperty("java.version"));
System.out.println("Operating System Name = " +
System.getProperty("os.name"));
System.out.println("Operating system architecture = " +
System.getProperty("os.arch"));
System.out.println("Operating system version = " +
System.getProperty("os.version") + "\n");
}
public static void main(String[] args){
outputMessage();
SimpleDateFormat sdf1;
SimpleDateFormat sdf2;
try {
sdf1 = new SimpleDateFormat("MM/dd/yyyy");
sdf1.setLenient(false);
java.util.Date d1 = sdf1.parse("10/28/98");
System.out.println("d1 is: " + d1.toString());
sdf2 = new SimpleDateFormat("MM/dd/yyyy");
sdf2.setLenient(false);
java.util.Date d2 = sdf2.parse("10/28/00");
System.out.println("d2 is: " + d2.toString());
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
}
}
(Review ID: 40256)
======================================================================
- relates to
-
JDK-4073644 parsing 1/1/00 gives back 1900
- Closed