This is an example explain how to convert from java.util.Date Object to java.sql.Date Object

public class MainClass {

  public static void main(String[] args) {
    java.util.Date utilDate = new java.util.Date();
    java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
    System.out.println("utilDate:" + utilDate);
    System.out.println("sqlDate:" + sqlDate);

  }

}
utilDate:Fri Feb 02 12:55:46 PST 2007
sqlDate:2007-02-02
Tagged:

Laisser un commentaire