1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
   |  
public static void main(String args[]) {
 
   String url = "jdbc:mysql://localhost:3306/test";
   Connection con = null;
 
   try {Class.forName("com.mysql.jdbc.Driver");
      con = DriverManager.getConnection(url,"root","");
      Statement stmt = con.createStatement();
 
   long timeMillis ;
   Date d = new Date((long)timeMillis);
   SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd hhmms");
   System.out.println(formatter.format(d));
 
 
   String updateLong = "UPDATE log" + "SET StartDate = d";
 
   stmt.executeUpdate(updateLong);
   String query = "SELECT StartDate FROM log" ;
 
ResultSet rs = stmt.executeUpdate(query);
 
 
   while(rs.next()){
       Date s = rs.getDate(2);
       System.out.println("Dates converties" + " :" + s );
   } | 
Partager