Hi Colin,
In my experience, I had to convert my java.util.Date type to
org.exolab.castor.types.Date.
Here is the castor date type:
http://www.castor.org/javadoc/org/exolab/castor/types/Date.html
You need to import org.exolab.castor.types.Date;
This is my code:
Date date = new Date();
short[] dateVals = {20,04,06,23}; //this date is
2004-06-23
date.setValues(dateVals);
item.setShipDate(date);
Hope this helps,
Anne
-----Original Message-----
From: Colin Harris [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 01, 2004 6:32 AM
To: [EMAIL PROTECTED]
Subject: [castor-user] java.lang.IllegalArgument when mapping
java.util.Date to constructor argument
Hi,
I have a simple class Trial with constructor
/** Creates a new instance of Trial */
public Trial(String trialName, String deviceFilename, String
usageFilename, Date start, Date end) {
this.trialName = trialName;
this.deviceFilename = deviceFilename;
this.usageFilename = usageFilename;
this.start = start;
this.end = end;
}
I am mapping the instance variables to the constructor arguments using
the mapping below. However, I get the exception
org.xml.sax.SAXException: unable to instantiate
com.colinharris.pm.analysis.Trial; java.lang.IllegalArgumentException:
argument type mismatch
when I include the two java.util.Date arguments. It works fine when I
only have the three String arguments. Am I doing something wrong?
thanks in advance
Colin.
<class name="com.colinharris.pm.analysis.Trial">
<field name="trialName" set-method="%1" get-method="getTrialName"
type="string">
<bind-xml node="attribute"/>
</field>
<field name="deviceFilename" set-method="%2"
get-method="getDeviceFilename" type="string">
<bind-xml node="attribute"/>
</field>
<field name="usageFilename" set-method="%3"
get-method="getUsageFilename" type="string">
<bind-xml node="attribute"/>
</field>
<field name="start" set-method="%4" get-method="getStart"
type="date">
<bind-xml node="attribute"/>
</field>
<field name="end" set-method="%5" get-method="getEnd" type="date">
<bind-xml node="attribute"/>
</field>
</class>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user