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

Reply via email to