| Author |
getDate() returning odd value
|
Jennifer Sohl
Ranch Hand
Joined: Feb 28, 2001
Posts: 455
|
|
I am using a DB2 database, and I have a row that has a value of '1900-01-01' of the Date type in a column. In my java application, when I do a getDate() (just printing to std out) on this column, it returns a value of 2011-06-30. What's up? Thanks for any help! [ February 11, 2003: Message edited by: Jennifer Sohl ] [ February 12, 2003: Message edited by: Jennifer Sohl ]
|
 |
Jon Dornback
Ranch Hand
Joined: Apr 24, 2002
Posts: 137
|
|
Originally posted by Jennifer Sohl: I am using a DB2 database, and I have a row that has a value of '1900-01-01' of the Date type in a column. In my java application, when I do a getDate() (just printing to std out) on this column, it returns a value of 2011-06-30. What's up? Thanks for any help! [ February 11, 2003: Message edited by: Jennifer Sohl ] [ February 12, 2003: Message edited by: Jennifer Sohl ]
the java Date class is very finicky - I have gotten different dates when converting from a String to a Date to a Calendar back to a String. So, you might want to look in to the ResultSet.getDate(String, Calendar). Or, if that doesn't work, look at the java.text.SimpleDateFormat class. With that, you can create rules on how to interpret a String as a Date, and then use ResultSet.getString() instead of .getDate() and parse the results. good luck. Jon
|
use the [CODE] tags - it makes it much easier for people to help you.
|
 |
Jennifer Sohl
Ranch Hand
Joined: Feb 28, 2001
Posts: 455
|
|
Thanks for the reply. However, I just found out what my problem was. It is in my connection. Here is what I had to do: Apparently DB2 wants you to specify the date format in the connection. After I added the "date format=iso" everything worked great!
|
 |
 |
|
|
subject: getDate() returning odd value
|
|
|