This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.Date and Oracle.

 
Alok Pota
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to able to insert date & time values in a DATE column of an Oracle table.
The following code
java.util.Date utilDate = new java.util.Date();
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
stmt.setDate(1, sqlDate);
sets the date in the column alright but the TIME is missing.
I need the value to be 8/31/2001 2:13:01 PM and not just
8/31/2001.
I can't change the table columns as they are fixed.
How do I go about inserting a date with its time in an Oracle
DATE column from the Java layer? (Note: I don't want to use the Oracle sysdate() function)
 
Yogen Vadnere
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Plz try following and let me know..
cst.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic