Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.0.1
-
Fix Version/s: 1.0.2
-
Component/s: Converters
-
Labels:None
Description
1.0.1 does not correctly handle the serialization and deserialization of Calendar instances. This is probably because they declare some member variables without initializers, and rely on the constructors providing good values ...
I've provided a test case and converter to solve the problem, but there may be a more elegant solution. The supplied converter simply uses a DateConverter to perform the work.
TestCase
=========
public void testCalendarCanBeReconstructed()
Fix
=======
public class CalendarConverter extends AbstractBasicConverter {
private DateConverter dateConverter = new DateConverter();
public boolean canConvert(Class type)
{ return Calendar.class.isAssignableFrom(type); }protected Object fromString(String str)
{ Date date = (Date) dateConverter.fromString(str); Calendar instance = Calendar.getInstance(); instance.setTime(date); return instance; }protected String toString(Object obj)
{ Calendar cal = (Calendar) obj; return dateConverter.toString(cal.getTime()); }}
Obviously, an addition to the DefaultConverterLookup is also required.
~Neil