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 java.sql.date 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();
transactionDate.setTimeInMillis(l_date.getTime());
}
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());
}
SqlStatement.setDate(
newPreparedStatement,
l_index++,
l_date);
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?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment