In my case I stored dates as longs and converted them in my field handlers because the version of castor I was using didn't have GregorianCalendar as a datatype.
Greg Farris -----Original Message----- From: Alagesan, Rajkumar [mailto:ralagesan@;ets.org] Sent: Wednesday, November 13, 2002 3:17 PM To: [EMAIL PROTECTED] Subject: Re: [castor-dev] FieldHandler question Going by the message it appears that the castor tries to construct the calendar object(and since it's an abstract class, it can't create one). But, I wonder why would castor even try instantiating when I have the field handler written for the field. Is it that my field handler never gets called before castor tries to create an instance of that type? Rajkumar -----Original Message----- From: Alagesan, Rajkumar Sent: Wednesday, November 13, 2002 3:12 PM To: [EMAIL PROTECTED] Subject: [castor-dev] FieldHandler question Hi, I try to use java.util.Collection for an xml field 'Birthdate' and wrote my Field Handler. I have written a mapping file that looks like <class name="org.ets.enterprise.profile.valueobject.PersonValueObject" > <field name="LanguageTypeCode" type="string"/> <field name="BirthDate" type="java.util.Calendar" handler="myHandler"/> </class> When I try to unmarshal the Xml, I get the following error java.lang.IllegalStateException: Java schema change: Class java.util.Calendar can no longer be const ructed: java.util.Calendar{file: [not available]; line: 3; column: 16} java.lang.NullPointerException my xml data file looks like this:- <?xml version="1.0" encoding="UTF-8"?> <person-value-object> <BirthDate>2002-10-3 11:10:50</BirthDate> <languagetypecode>1</languagetypecode> </personvalueobject> myHandler.java code import org.exolab.castor.mapping.GeneralizedFieldHandler; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class myHandler extends GeneralizedFieldHandler{ public java.lang.Class getFieldType(){ return java.util.Calendar.class; } public java.lang.Object convertUponSet(java.lang.Object value){ Calendar c = null; try{ SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-yy hh:mm:ss"); Date d = formatter.parse((String)value); c= Calendar.getInstance(); c.setTime(d); } catch(Exception e){ System.out.println("setvalue"+e); } return c; } public java.lang.Object convertUponGet(java.lang.Object value){ Calendar c = (Calendar)value; Date d = c.getTime(); SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-yy hh:mm:ss"); String s = formatter.format(d); return s; } } Let me know where I am going wrong? Thanks, Raj ************************************************************************** This e-mail and any files transmitted with it may contain privileged or confidential information. It is solely for use by the individual for whom it is intended, even if addressed incorrectly. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited. Thank you for your compliance. ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ************************************************************************** This e-mail and any files transmitted with it may contain privileged or confidential information. It is solely for use by the individual for whom it is intended, even if addressed incorrectly. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited. Thank you for your compliance. ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev **************************************************************************** This email may contain confidential material. If you were not an intended recipient, Please notify the sender and delete all copies. We may monitor email to and from our network. **************************************************************************** ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
