File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL to Java Date Inaccuracy" Watch "MySQL to Java Date Inaccuracy" New topic
Author

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.
Tom
[ 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.


Bosun (SCJP, SCWCD)
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: http://aspose.com/file-tools
 
subject: MySQL to Java Date Inaccuracy
 
Similar Threads
expected:5 but was:5.0000000
Issue calling MYSQL Stored Proc using Hibernate JPA
new words
BiTSet storage and comparaison
compare year and date ??