|
From: SourceForge.net <no...@so...> - 2012-01-25 13:19:22
|
Bugs item #3479543, was opened at 2012-01-25 02:17 Message generated for change (Comment added) made by jeffjensen You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=449491&aid=3479543&group_id=47439 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Bug Group: v2.4.* Status: Open Resolution: None Priority: 5 Private: No Submitted By: Tobias Buchloh (tbuchloh) >Assigned to: Jeff Jensen (jeffjensen) Summary: TimestampDataType cannot typeCast correct Timestamp strings Initial Comment: = Problem = We want to migrate dbunit from v2.2 to v2.4.8 and are now faced with the problem that some of our test cases do not work anymore due to changes in org.dbunit.dataset.datatype.TimestampDataType.typeCast(Object). In v2.2 the string "2010-05-19 08:38:45.123456" was converted into a correct java.sql.Timestamp-object. With v2.4.8 it will be converted silently to "2010-05-19 08:40:48.456" which is definitely not what we expected. = Possible cause = Looking in the code we found a problem beginning on line 91: <snip> try { // SimpleDateFormat uses millisecond precision only DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); Date date = df.parse(stringValue); return new java.sql.Timestamp(date.getTime()); } catch (ParseException e) { if (i < patterns.length) continue; throw new TypeCastException(value, this, e); } </snap> Using SimpleDateFormat for a nano precision type does not work, because it creates a java.util.Date-object which does not work with nanoseconds. In v2.2 the method Timestamp.valueOf(String) has been used. ---------------------------------------------------------------------- >Comment By: Jeff Jensen (jeffjensen) Date: 2012-01-25 05:19 Message: Thank you for finding the problem. Please attach tests and a patch and I will apply to trunk. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=449491&aid=3479543&group_id=47439 |