wood burning stoves 2.0*
The moose likes JDBC 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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
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.
jQuery in Action, 2nd edition
subject: MySQL to Java Date Inaccuracy
Similar Threads
new words
BiTSet storage and comparaison
expected:5 but was:5.0000000
Issue calling MYSQL Stored Proc using Hibernate JPA
compare year and date ??