Wednesday, December 21, 2005

Java Gregorian calendar

Is it just me or do others also hate the gregorian calendar implementation in java? The problem arises when saving a date to a database. As you know, we save the date as a format. So first, in my data acess object, I have to do the following conversion code:

Date l_date = newResultSet.getDate("transaction_date");
if(l_date != null){
transactionDate= new GregorianCalendar();

And then of course when saving back to the database, I must use the following code:

java.sql.Date l_date = null;
if(newRow.getTransactionDate() != null){
l_date = new java.sql.Date(newRow.getTransactionDate().getTimeInMillis());


I do all of this because the setYear method, setMonth method, and constructor with params for day, month, and year are depricated for the java.sql.Date and java.util.Date classes. And I am one of those people who absolutely hates seeing the stupid warning signs in eclipse saying "method x is depricated". So, there's my rant. What do you all think?

No comments: