Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String to sql.date

 
syidah mk
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi.. i need help in converting string to date.. i just need someone to check whether my code is correct or not..

here are my codes:


Date today = new Date();
DateFormat formatLong= DateFormat.getDateInstance(DateFormat.SHORT);
java.sql.Date curDate = java.sql.Date.valueOf(formatLong.format(today));

//and below is the storing part..

String query1 = null;
query1 = "Insert into ITS.dbo.orderDetails values(?)";

PreparedStatement stmnt = conn.prepareStatement(query1);


stmnt.setDate(1, curDate);

stmnt.executeUpdate();





anyone ..pls reply .. i need it urgently...
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is that urgent, why don't you try it and see if it works? It looks like it might.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic