Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date format

 
John King
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a java.sql.Date object in following way and insurted it in my_table

Date d = new Date(System.System.currentTimeMillis());


When I use SQL+ to check, I found that no hour, minute, and second info:

SQL> select TO_CHAR(my_dt, 'mm-dd-yyyy hh24:mi:ss') as My_dt from my_table;

MY_DT
-------------------
08-24-2004 00:00:00
08-24-2004 00:00:00
08-24-2004 00:00:00
08-24-2004 00:00:00
08-24-2004 00:00:00

Could anyone tell me why? I'm using Oracle. Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.sql.Date is just a date (unlike java.util.Date). If you want to store a timestamp, use java.sql.Timestamp.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic