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 29 30 31 32 33
|
import java.io.PrintStream;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.*;
import java.time.LocalDate;
import java.time.Month;
import java.time.format.DateTimeFormatter;
import com.sdzee.*;
public class testeDate {
public static void main(String[]args) throws ParseException, SQLException {
Statement st=connexion.connecter();
String strDate = "31-12-2011";
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
java.sql.Date effect_from = new java.sql.Date(formatter.parse(strDate).getTime());
//System.out.println("String converted to java.sql.Date :" + effect_from);
int statut = st.executeUpdate( "insert into testdate values('"+effect_from+"')" );
}
} |
Partager