Hello all,

How do I control how JiBX formats output. 

Let's say Date attributes. I have some attributes in the class which are of
type java.util.Date.

When I map them directly in mapping element like this:

      <value name="OrigDate" field="origDate" />

I get the output in the output XML file but the date string format is not
what I want. It's uses some default formatter. I'd like it to be in this
format: "MM/DD/YY"

I can use SimpleDateFormat to format a date, but when I map in JiBX, is
there a way to specify a formatter class and format string? 

What about out types like Doubles, BigDecimal etc.. I'd like to have control
of how those data types are displayed in XML file..  Is there a generic
approach I should use?


I guess I could use: set-method="setDateFormatForOrigDate"
get-method="getDateFormatForOrigDate"  and implement those methods on the
object to get the data in the format I need, but this DOES not look right to
me.

I'd wind up with methods that are really not used anywhere but for this
formatting purpose. Plus JiBX does REQUIRE you to have a set-method in this
case and for some of my fields, it will not really work, cause I have fields
that are my custom classes and creating object of that type just for the
purpose of setting one of it's attributes (per JiBX requirement) does not
make sense.

There has to be a better way to format output and have control of how each
field is outputted.

Your suggestings are really appreciated.

Regards,

Dmitry.
 






-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to