In the JDBC API, there were only 2 constructor for java.sql.Date. One of it already depreciated. The only one left is:
java.sql.Date(long date)It is the same for java.sql.Time and java.sql.Timestamp. It really sound not logic to me. Since most of the time we use java.util.Date for datetime manipulation, java.util.Date and java.sql.Date should be interchangeable. Or at least java.sql.Date should have a constructor that accept java.util.Date as parameter.
Let look at the code below:
java.util.Date date = new java.util.Date();I hope next version of JDK or JDBC will see some improvement on this.
//
// Date manipulation here
//
// This look natural, but this is INVALID
java.sql.Date sqlDate = new java.sql.Date(date);
// this is VALID, but do not make sense
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
No comments:
Post a Comment