Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Date with an extra Zero appended to the Seconds

807589Aug 25 2008 — edited Aug 25 2008
Hello everyone,
I'm new to Java and this might sound like a very silly question.
In the database, I have a date field in which the date is stored in the following format:
8/25/2008 6:38:18 PM

Hibernate is being used to retrieve data from the database and to populate the corresponding Java Object. The java property in the obkect that stores the date is java.util.Date.

The same Date object when I print it using the toString method, it displays in the following format:
2008-08-25 18:38:18.0

I fail to understand what that 0 is doing after the seconds (18:38:18.0) - I dont know how to remove it. Even if I try SimpleDateFormat to only display date as yyyy-mm-dd HH:MM:ss - I get a parse exception.

Can anyone tell me - why that trailing zero is appearing after the second and how I can get rid of it.
Appreciate it.
Thanks
--Gubloo
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 22 2008
Added on Aug 25 2008
6 comments
1,322 views