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 MySQL to Java Date Inaccuracy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "MySQL to Java Date Inaccuracy" Watch "MySQL to Java Date Inaccuracy" New topic

MySQL to Java Date Inaccuracy

Thomas Hubschman
Ranch Hand

Joined: Sep 25, 2002
Posts: 88
Hello fellow ranchers,
I am reading a DATE column from a MySQL table and am having a conversion problem. The date is stored is stored as:

But when read into a GregorianCalendar via

It looses a month to

Can any one help me out with this one???
Thanks much.
[ November 28, 2003: Message edited by: Thomas Hubschman ]

SCJP '02, SCWCD '02, SCJD '08, SCSNB '09, SCEA '10
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Not sure exactly what the conversion is going wrong. Remember that monthhs in Gregorian Calendar a zero based. i.e. January = 0.

So much trouble in the world -- Bob Marley
Thomas Hubschman
Ranch Hand

Joined: Sep 25, 2002
Posts: 88
Thanks that was it.
I'm not sure what genius thought that up. It should be at least corrected in the JDBC driver so datatypes don't require an bizzare ++MONTH exression.
I agree. Here's the link:
subject: MySQL to Java Date Inaccuracy
It's not a secret anymore!