File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Date format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Date format" Watch "Date format" New topic

Date format

John King
Ranch Hand

Joined: Aug 27, 2002
Posts: 165
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;

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

Joined: Jan 10, 2002
Posts: 63873

java.sql.Date is just a date (unlike java.util.Date). If you want to store a timestamp, use java.sql.Timestamp.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Date format
It's not a secret anymore!