Relates :
|
|
Relates :
|
|
Relates :
|
As per the API doc for java.sql.Date.valueOf, IllegalArgumentException should be thrown if the date given is not in the JDBC date escape format (yyyy-mm-dd). The error is not thrown when I enter the value '20009-10-10'. Instead it silently stores the value. But later when I do java.sql.toString() public static void main(String[] args) { java.sql.Date jsd = java.sql.Date.valueOf("20009-06-26"); System.out.println(jsd); } The above program prints *009-06-26 Where '*' is a non-readable character. We need fix in valueOf method() to throw the exception if we pass 5 digits to the API. From API valueOf public static Date valueOf(String s) Converts a string in JDBC date escape format to a Date value. Parameters: s - a String object representing a date in in the format "yyyy-mm-dd" Returns: a java.sql.Date object representing the given date Throws: IllegalArgumentException - if the date given is not in the JDBC date escape format (yyyy-mm-dd)
|