Replace DateConverter's and TimeConverter's use of deprecated constructors
--------------------------------------------------------------------------
Key: DDLUTILS-57
URL: http://issues.apache.org/jira/browse/DDLUTILS-57
Project: DdlUtils
Type: Improvement
Reporter: Ken Weiner
Assigned to: Thomas Dudziak
Both DateConverter and TimeConverter use deprecated constructors of
java.sql.Date and java.sql.Time respectively. This request is to replace the
use of those constructors with a non-deprecated one.
I am attaching a patch file that fixes both the DateConverter and TimeConverter
to make use of the Calendar object to contruct the dates and times.
This patch also adds a check to the convertToString methods to check the type
of the object, throwing an exception if the object is not of the expected type.
I also wrote some unit tests, DateConverterTest and TimeConverterTest to
accompany these changes.
Note: Before applying this patch, you could have called the convertFromString()
methods with invalid text representations and the methods would have returned
an unexpected date. Now with the use of Calendar, this won't happen since the
Calendar instance has been set to not be "lenient". See
DateConverterTest.testConvertFromStringWithInvalidTextRep() and
TimeConverter.testConvertFromStringWithInvalidTextRep(). These test methods do
not pass with the current code, but do pass after applying this patch.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira