Java67 - Java Program Example Tutorial Blog

Java67 - Java Program Example Tutorial Blog


How to convert java.sql.Date to java.util.Date in Java with Example

Posted: 24 Dec 2012 02:07 AM PST

How to convert java.sql.Date into java.util.Date and vice-versa is a popular JDBC interview question which is also asked as follow-up question of difference between java.sql.Date and java.util.Date which we have saw in our last article. Since both SQL date and Util date stores values as long millisecond , its easy to convert them back and forth. Both java.sql.Date and java.util.Date provides convenient method called getTime() which returns long millisecond equivalent of wrapped date value. Here is quick example of converting java.util.Date to java.sql.Date and then back to util Date. This article is in next of earlier post on Java Date and Time API  like How to convert Date to String and How to find current Date and Timestamp in Java on any timezone. if you haven't read them already you may find them useful.
Read more »


Post a Comment