Hi,
You will have to write a custom handler :
Here is an example code for the handler and its useage:
Cheers,
Subbu
package com.test;
import java.util.Date;
import java.text.*;
import org.exolab.castor.mapping.GeneralizedFieldHandler;
import java.text.*;
import org.exolab.castor.mapping.GeneralizedFieldHandler;
public class MyDateFieldHandler extends GeneralizedFieldHandler
{
public final DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
{
public final DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
public MyDateFieldHandler()
{
}
{
}
public Object convertUponGet(Object value)
{
{
String retValue = null;
if(value != null)
retValue = format.format(value);
if(value != null)
retValue = format.format(value);
return retValue;
}
public Object convertUponSet (Object value)
{
if(value != null)
{
{
if(value != null)
{
String dateStr = (String) value;
try
{
Date date1 = (Date) format.parse(dateStr);
return date1;
}
catch (ParseException e)
{
try
{
Date date1 = (Date) format.parse(dateStr);
return date1;
}
catch (ParseException e)
{
throw new RuntimeException(e);
}
}
else
return null;
}
public Class getFieldType()
{
return java.lang.String.class;
}
}
}
}
else
return null;
}
public Class getFieldType()
{
return java.lang.String.class;
}
}
And in the mapping file following entry need to done:
<field name="dob" handler="com.test.MyDateFieldHandler " type = "java.lang.String" >
<bind-xml name="dob" node="element" />
</field>
<bind-xml name="dob" node="element" />
</field>
"Mounagurusamy, Jayakumar (HAL)" <[EMAIL PROTECTED]> wrote:
Hello All,
I am trying to marshal a java.util.Date object to of format "mmddccyy",
by default castor does this format2004-09-04T00:00:00.000-07:00 . Is there any way for
me to specify the string Date format that I want in the XML and vice
versa
Any help will be appreciated
Thanks
Jay
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
"ignorance is bliss"
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
