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!

Errros in formatting dates with milliseconds

807569Sep 28 2006 — edited Sep 28 2006
I am writing a routine to convert a String to a Date.

I have created the following mask: "yyyy-MM-dd HH:mm:ss.SSSSS"

I pass this to SimpleDateFormat and then parse to return a java.util.Date.

The method works fine when the milliseconds are all zero, ie .00012. however when the milliseconds increase, the resuting time in the date object becomes anywhere from a minute to hours later than it should be.

For instance, "2006-09-28 10:23:16.214500" becomes
Thu Sep 28 10:26:50 EDT 2006 when the resulting date object is displayed.

Is this a bug with java 1.5?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 26 2006
Added on Sep 28 2006
10 comments
349 views