• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String to sql.date

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic