Convert Java to XML with Smooks - Format date

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Convert Java to XML with Smooks - Format date

Gaël Varlet
I want to convert a Java Object to XML using Smooks.

The class is

    MyClass{
      private java.util.Date myDate;
      //constructors, getters and setters
    }

My smooks' configuration is :

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd">
      <resource-config selector="global-parameters">
        DOM
      </resource-config>

      <resource-config selector="fr.test.model.MyClass">
    <resource>org.milyn.cdres.trans.RenameElementTU</resource>
    class
      </resource-config>
    </smooks-resource-list>

But, with such a configuration, I get this kind of XML :

    <class><myDate>2012-03-03 23:00:00.0 UTC</myDate></class>

Is it possible to convert/format myDate to "03-03-2012" without using Freemaker and directly with the file smooks-config.xml ?
Gael Varlet
Reply | Threaded
Open this post in threaded view
|

Re: Convert Java to XML with Smooks - Format date

Tom Fennelly
Hi.

Look at using a FreeMarker template for doing this.

Regards,

Tom.

On 29/07/2013 16:24, Gaël Varlet wrote:

> I want to convert a Java Object to XML using Smooks.
>
> The class is
>
>      MyClass{
>        private java.util.Date myDate;
>        //constructors, getters and setters
>      }
>
> My smooks' configuration is :
>
>      <?xml version="1.0" encoding="ISO-8859-1"?>
>      <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd">
>        <resource-config selector="global-parameters">
>          DOM
>        </resource-config>
>
>        <resource-config selector="fr.test.model.MyClass">
>       <resource>org.milyn.cdres.trans.RenameElementTU</resource>
>       class
>        </resource-config>
>      </smooks-resource-list>
>
> But, with such a configuration, I get this kind of XML :
>
>      <class><myDate>2012-03-03 23:00:00.0 UTC</myDate></class>
>
> Is it possible to convert/format myDate to "03-03-2012" without using
> Freemaker and directly with the file smooks-config.xml ?
>
>
>
> -----
> Gael Varlet
> --
> View this message in context: http://milyn.996300.n3.nabble.com/Convert-Java-to-XML-with-Smooks-Format-date-tp8643.html
> Sent from the milyn - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email