camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@fusesource.com>
Subject Re: Date String Creation
Date Wed, 07 Dec 2011 18:43:22 GMT
Hi,

If you don't mind using XQuery as an expression language for achieving
this, you could use the following instead of using a Bean. IMHO, this is
more natural, as it uses XML languages themselves to spit out an
XML-compliant dateTime format ;)

 <setHeader headerName="myDate">
    <xquery type="java.lang.String" xmlns:xs="
http://www.w3.org/2001/XMLSchema">xs:dateTime(current-dateTime()) -
xs:dayTimeDuration('P1D')</xquery>
  </setHeader>
Couple of things:

   - Providing the type is absolutely necessary (java.lang.String in the
   above example)
   - You need to specify the XML Schema namespace. If you want the
   expression XML element to be lighter, you could push up the namespace
   declaration to the <route>, <camelContext> element or above
   - You can construct the duration dynamically by using the concat()
   function.
   - Make sure that camel-saxon is on your classpath, or that the
   camel-saxon feature is installed if you are using ServiceMix/Karaf -
   whatever is relevant in your case.

Hope this helps.

Regards,
Raúl.

On 7 December 2011 16:00, Claus Ibsen <claus.ibsen@gmail.com> wrote:

> On Wed, Dec 7, 2011 at 4:47 PM, Castyn <eric.bender@gmail.com> wrote:
> > So if I declared a bean with id of getLastRunDate that returned a string
> of
> > the appropriate date format, how do you actually call that in the Spring
> DSL
> > to set a header?
> >
>
> Use the method call expression, something a like this:
>
> <setHeader headerName="myDate">
>   <method ref="myBean" method="getLastRunDate"/>
> </setHeader>
>
>
>
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Date-String-Creation-tp5052753p5056060.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message