In the example I did use the <format> tag.  Because of this, in the
<value> tag, I just need to use the format attribute.  Otherwise I would
have had tousing the serializer, deserializer attributes in the
following fashion each time I need to use that format:
...
<value name="date" field="date"
serializer="com.mystuff.Converter.serializeDashDate
deserializer="com.mystuff.Converter.deserializeDashDate"/>
...
<value name="createdOn" field="date"
serializer="com.mystuff.Converter.serializeDashDate
deserializer="com.mystuff.Converter.deserializeDashDate"/>
...

Just to show the difference, with format pre-define I would have:
...
<format label="DashDate"
serializer="com.mystuff.Converter.serializeDashDate"
deserializer="com.mystuff.Converter.deserializeDashDate"/>
...
<value name="date" field="date" format="DashDate"/>
...
<value name="createdOn" field="date" format="DashDate"/>
...

As you can see, a lot less typing for me ;-)

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ronald
Johnson
Sent: Friday, March 16, 2007 12:11 PM
To: JiBX users
Subject: Re: [jibx-users] mapping to java.util.Date?

that is, an example without using serializer :) (you wrote) <format> tag
(my preference) or directly the serializer,

or do i always have to create the serialier method that are called from
the format tag?


On 3/16/07, Ronald Johnson <[EMAIL PROTECTED]> wrote:
> cheers for the quick reply,
>
> can you give an example on how to use the format tag in the
binding.xml ?
>
>
>
> On 3/16/07, Stephan Bourges <[EMAIL PROTECTED]> wrote:
> > You can use the <format> tag (my preference) or directly the 
> > serializer, deserializer attribute with a custom made formater (the 
> > one provided use the - separators).
> >
> > In a class you need the following methods:
> >
> > public static String serializeDashDate(java.util.Date date) {
> >         return sdf.format(date);
> > }
> > public static java.util.Date deserializeDashDate(String date) {
> >         return sdf.parse(date);
> > }
> > private static java.text.SimpleDataFormat sdf=new 
> > java.text.SimpleDataFormat("yyyy-mm-dd");
> >
> > Then in your binding file:
> > <binding>
> >         <format label="DashDate"
> > serializer="com.mystuff.Converter.serializeDashDate"
> > deserializer="com.mystuff.Converter.deserializeDashDate"/>
> >         <mapping..>
> >                 <value name="date" field="date" format="DashDate"/>
> >                 ..
> >         </mapping>
> > </binding>
> >
> > I didn't really compile any of the above, but that should get you
there.
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of 
> > Ronald Johnson
> > Sent: Friday, March 16, 2007 11:53 AM
> > To: [email protected]
> > Subject: [jibx-users] mapping to java.util.Date?
> >
> > hm, i cant find an example for this:
> >
> > i want to map xml element of the form
> >
> > <somedate>31.12.2004</somedate>
> >
> > to an attribute of type java.util.Date Date someDate;
> >
> > how can this be done?
> >
> > --------------------------------------------------------------------
> > ----
> > -
> > Take Surveys. Earn Cash. Influence the Future of IT Join 
> > SourceForge.net's Techsay panel and you'll get the chance to share 
> > your opinions on IT & business topics through brief surveys-and earn

> > cash 
> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=D
> > EVDE
> > V
> > _______________________________________________
> > jibx-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/jibx-users
> >
> >
> > --------------------------------------------------------------------
> > ----- Take Surveys. Earn Cash. Influence the Future of IT Join 
> > SourceForge.net's Techsay panel and you'll get the chance to share 
> > your opinions on IT & business topics through brief surveys-and earn

> > cash 
> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=D
> > EVDEV _______________________________________________
> > jibx-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/jibx-users
> >
>

------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT Join
SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to