R
Rajesh Patel
I have a date format of MM-dd-yyyy and pass 12-12-198x into
parse, I expect this to be invalid. The following program
will print out:
Tue Dec 12 00:00:00 CST 0198.
I expect an exception, anybody know how to work around this?
import java.io.*;
import java.text.*;
import java.util.*;
public class SimpleDate {
public static void main(String s[]) throws Exception {
SimpleDateFormat formatter = new
SimpleDateFormat("MM-dd-yyyy");
formatter.setLenient(false);
Date date = formatter.parse("12-12-198x");
System.out.println(date);
}
}
parse, I expect this to be invalid. The following program
will print out:
Tue Dec 12 00:00:00 CST 0198.
I expect an exception, anybody know how to work around this?
import java.io.*;
import java.text.*;
import java.util.*;
public class SimpleDate {
public static void main(String s[]) throws Exception {
SimpleDateFormat formatter = new
SimpleDateFormat("MM-dd-yyyy");
formatter.setLenient(false);
Date date = formatter.parse("12-12-198x");
System.out.println(date);
}
}