Sunday, April 13, 2014

How to convert Java Date to Java SQL Date

Java uses java.util.Date to store the Date value. But it uses java.sql.Date to retrieve the Date from the MySQL or SQL Server.

This post explains on how to store date (java.util.Date) into the MySQL/SQL Server Date. 

java.util.Date javaDate = new java.util.Date();
java.text.SimpleDateFormat dateformat = new java.awt.SimpleDateFormat("YYYY-MM-DD HH:MM:SS");
String sqlTime = dateformat.format(javaDate);

Share this

0 Comment to "How to convert Java Date to Java SQL Date"

Post a Comment