Maybe I missed out on part of your problem, but can't you use a
GeneralizedFieldHandler to do this?

You can convert a java.util.Date from a String (in the XML file) to a
java.util.Date that gets set in your object and visa-versa.  Just create
a GeneralizedFieldHandler that performs the conversion from
java.util.Date to java.lang.String and visa versa (using DateFormat?). 

For now you also need to specify a "handler" attribute for each
java.util.Date field in  your mapping file.  The handler attribute should
be the class name of your GeneralizedFieldHandler.  

Keith is going to fix the java.util.Date support for FieldHandlerFactory
soon.  When that is working, you can simply create a FieldHandlerFactory
that returns your GeneralizedFieldHandler whenever a java.util.Date field
is being processed.  Very cool.

Good luck,
Jeremy


On Wed, 04 Feb 2004 18:58:04 +0000, "Renato Torres"
<[EMAIL PROTECTED]> said:
> I had the same problem, i.e., the class that I wanted to un/marshall had 
> a field of type java.util.Date.
> 
> I've done it like this:
> - Imagine that you have a field called birthDate (getter='getBirthDate', 
> setter='setBirthDate'), of type java.util.Date
> - I created two methods "String getBirthDateAsString()" and "void 
> setBirthDateFromString(String date)" that are used in the mapping file 
> (see <field> tag attributes "set-method" and "get-method"), but that 
> internally use the java.util.Date field.
> - To convert between String and Date I used the DateFormat class.
> 
> Regards,
> 
> Renato
> 
> Munuswamy-Ramu Senthilkumar wrote:
> 
> > Hi,
> >
> > Thanks lot.
> >
> > But if i use the type java.util.Date.
> >
> > Any idea how to solve it.
> >
> > Because i cann't change the type.
> >
> > if i want to change the type from java.util.Date into String , the impact
> > on code change is more.
> >
> >
> >
> > thanks & regards,
> > senthil
> >
> >
> >
> >
> >
> >
> > Renato Torres <[EMAIL PROTECTED]>
> > 04.02.2004 18:20
> >
> >
> > To: Munuswamy-Ramu Senthilkumar/ext/[EMAIL PROTECTED]
> > cc:
> > Subject: Re: [castor-dev] java.util.Date: unmarshall problem
> >
> >
> > Hi.
> > Check this <http://hypermail.linklord.com/castor-dev/2003/Nov/1731.html>
> > thread for the solution that I used.
> >
> > Regards,
> >
> > Renato
> >
> > Munuswamy-Ramu Senthilkumar wrote:
> >
> >> Hi renato,
> >>
> >>
> >> I am facing same problem.
> >>
> >> Do you any idea to solve it?
> >>
> >> Let me know.
> >>
> >>
> >> Thanks & Regards,
> >> senthil
> >>
> >>
> >>
> >
> >
> >
> >
> >
> 
> ----------------------------------------------------------- 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev
> 
-- 
  Jeremy Haile
  [EMAIL PROTECTED]

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to