You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ski n <ra...@gmail.com> on 2021/11/26 12:17:50 UTC
Simple language
Hi all,
I have two questions regarding simple expressions:
1) Is it possible the get the time in miliseconds. Something like
${data:now.toMilli}
2) Is it possible to calculate with the simple language
${1 +1}
Kind regards,
Raymond
Re: Simple language
Posted by ski n <ra...@gmail.com>.
That's pretty cool, worked for me!
Raymond
Op vr 26 nov. 2021 om 18:19 schreef Daniel Langevin <
daniel.langevin@shq.gouv.qc.ca>:
> OK here is a solution to get UnixTimeStamp in SIMPLE LANGUAGE camel 2.xx
>
> <setHeader headerName="wTimeStamp"><simple
> resultType="java.util.Date">${header.CamelCreatedTimestamp}</simple></setHeader>
> <setHeader
> headerName="wUnixTimeStamp"><simple>${header.wTimeStamp.getTime()/1000}</simple></setHeader>
> <log message="wUnixTimeStamp = ${header.wUnixTimeStamp}"/>
>
>
> Hope it's help!
>
>
> Daniel Langevin
>
>
> -----Message d'origine-----
> De : ski n <ra...@gmail.com>
> Envoyé : 26 novembre 2021 09:48
> À : users@camel.apache.org
> Objet : Re: Simple language
>
> Thanks Daniel,
> I wasn't clear, what I meant is a Unix time in milliseconds. For example
>
> 1637937665
>
> I now use Groovy for this:
>
> .setHeader("MyHeader").groovy("new Date().getTime()")
>
> And I use Groovy (or a Java bean) to do calculations (not increments which
> is of course possible with simple)
>
> But I am now in an environment where Groovy is not on the classpath (Camel
> XML DSL code is exactly generated) and I can only use the simple language.
>
> Greets,
>
> Raymond
>
>
> Op vr 26 nov. 2021 om 14:40 schreef Daniel Langevin <
> daniel.langevin@shq.gouv.qc.ca>:
>
> > Sorry to fast for time,
> >
> > Here is: <simple>${date:now:yyyy-MM-dd' à 'HH:mm:ss.fff'
> > ('yyy'.'D')'}</simple>
> >
> >
> >
> > Daniel
> >
> > -----Message d'origine-----
> > De : Daniel Langevin <da...@shq.gouv.qc.ca> Envoyé : 26
> > novembre 2021 08:37 À : users@camel.apache.org Objet : RE: Simple
> > language
> >
> > Hi Raymond,
> >
> > For date:
> > <simple>${date:now:yyyy-MM-dd' à 'HH:mm:ss' ('yyy'.'D')'}</simple>
> >
> >
> > For addition 1 to value of Var1
> > <simple>${header.Var}++</simple>
> >
> > Regards
> >
> > Daniel Langevin
> >
> > -----Message d'origine-----
> > De : ski n <ra...@gmail.com>
> > Envoyé : 26 novembre 2021 07:18
> > À : users@camel.apache.org
> > Objet : Simple language
> >
> > Hi all,
> >
> > I have two questions regarding simple expressions:
> >
> > 1) Is it possible the get the time in miliseconds. Something like
> >
> > ${data:now.toMilli}
> >
> > 2) Is it possible to calculate with the simple language
> >
> > ${1 +1}
> >
> > Kind regards,
> >
> > Raymond
> >
>
RE: Simple language
Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
OK here is a solution to get UnixTimeStamp in SIMPLE LANGUAGE camel 2.xx
<setHeader headerName="wTimeStamp"><simple resultType="java.util.Date">${header.CamelCreatedTimestamp}</simple></setHeader>
<setHeader headerName="wUnixTimeStamp"><simple>${header.wTimeStamp.getTime()/1000}</simple></setHeader>
<log message="wUnixTimeStamp = ${header.wUnixTimeStamp}"/>
Hope it's help!
Daniel Langevin
-----Message d'origine-----
De : ski n <ra...@gmail.com>
Envoyé : 26 novembre 2021 09:48
À : users@camel.apache.org
Objet : Re: Simple language
Thanks Daniel,
I wasn't clear, what I meant is a Unix time in milliseconds. For example
1637937665
I now use Groovy for this:
.setHeader("MyHeader").groovy("new Date().getTime()")
And I use Groovy (or a Java bean) to do calculations (not increments which is of course possible with simple)
But I am now in an environment where Groovy is not on the classpath (Camel XML DSL code is exactly generated) and I can only use the simple language.
Greets,
Raymond
Op vr 26 nov. 2021 om 14:40 schreef Daniel Langevin <
daniel.langevin@shq.gouv.qc.ca>:
> Sorry to fast for time,
>
> Here is: <simple>${date:now:yyyy-MM-dd' à 'HH:mm:ss.fff'
> ('yyy'.'D')'}</simple>
>
>
>
> Daniel
>
> -----Message d'origine-----
> De : Daniel Langevin <da...@shq.gouv.qc.ca> Envoyé : 26
> novembre 2021 08:37 À : users@camel.apache.org Objet : RE: Simple
> language
>
> Hi Raymond,
>
> For date:
> <simple>${date:now:yyyy-MM-dd' à 'HH:mm:ss' ('yyy'.'D')'}</simple>
>
>
> For addition 1 to value of Var1
> <simple>${header.Var}++</simple>
>
> Regards
>
> Daniel Langevin
>
> -----Message d'origine-----
> De : ski n <ra...@gmail.com>
> Envoyé : 26 novembre 2021 07:18
> À : users@camel.apache.org
> Objet : Simple language
>
> Hi all,
>
> I have two questions regarding simple expressions:
>
> 1) Is it possible the get the time in miliseconds. Something like
>
> ${data:now.toMilli}
>
> 2) Is it possible to calculate with the simple language
>
> ${1 +1}
>
> Kind regards,
>
> Raymond
>
Re: Simple language
Posted by ski n <ra...@gmail.com>.
Thanks Daniel,
I wasn't clear, what I meant is a Unix time in milliseconds. For example
1637937665
I now use Groovy for this:
.setHeader("MyHeader").groovy("new Date().getTime()")
And I use Groovy (or a Java bean) to do calculations (not increments
which is of course possible with simple)
But I am now in an environment where Groovy is not on the classpath
(Camel XML DSL code is exactly generated) and I can only use the
simple language.
Greets,
Raymond
Op vr 26 nov. 2021 om 14:40 schreef Daniel Langevin <
daniel.langevin@shq.gouv.qc.ca>:
> Sorry to fast for time,
>
> Here is: <simple>${date:now:yyyy-MM-dd' à 'HH:mm:ss.fff'
> ('yyy'.'D')'}</simple>
>
>
>
> Daniel
>
> -----Message d'origine-----
> De : Daniel Langevin <da...@shq.gouv.qc.ca>
> Envoyé : 26 novembre 2021 08:37
> À : users@camel.apache.org
> Objet : RE: Simple language
>
> Hi Raymond,
>
> For date:
> <simple>${date:now:yyyy-MM-dd' à 'HH:mm:ss' ('yyy'.'D')'}</simple>
>
>
> For addition 1 to value of Var1
> <simple>${header.Var}++</simple>
>
> Regards
>
> Daniel Langevin
>
> -----Message d'origine-----
> De : ski n <ra...@gmail.com>
> Envoyé : 26 novembre 2021 07:18
> À : users@camel.apache.org
> Objet : Simple language
>
> Hi all,
>
> I have two questions regarding simple expressions:
>
> 1) Is it possible the get the time in miliseconds. Something like
>
> ${data:now.toMilli}
>
> 2) Is it possible to calculate with the simple language
>
> ${1 +1}
>
> Kind regards,
>
> Raymond
>
RE: Simple language
Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Sorry to fast for time,
Here is: <simple>${date:now:yyyy-MM-dd' à 'HH:mm:ss.fff' ('yyy'.'D')'}</simple>
Daniel
-----Message d'origine-----
De : Daniel Langevin <da...@shq.gouv.qc.ca>
Envoyé : 26 novembre 2021 08:37
À : users@camel.apache.org
Objet : RE: Simple language
Hi Raymond,
For date:
<simple>${date:now:yyyy-MM-dd' à 'HH:mm:ss' ('yyy'.'D')'}</simple>
For addition 1 to value of Var1
<simple>${header.Var}++</simple>
Regards
Daniel Langevin
-----Message d'origine-----
De : ski n <ra...@gmail.com>
Envoyé : 26 novembre 2021 07:18
À : users@camel.apache.org
Objet : Simple language
Hi all,
I have two questions regarding simple expressions:
1) Is it possible the get the time in miliseconds. Something like
${data:now.toMilli}
2) Is it possible to calculate with the simple language
${1 +1}
Kind regards,
Raymond
RE: Simple language
Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Hi Raymond,
For date:
<simple>${date:now:yyyy-MM-dd' à 'HH:mm:ss' ('yyy'.'D')'}</simple>
For addition 1 to value of Var1
<simple>${header.Var}++</simple>
Regards
Daniel Langevin
-----Message d'origine-----
De : ski n <ra...@gmail.com>
Envoyé : 26 novembre 2021 07:18
À : users@camel.apache.org
Objet : Simple language
Hi all,
I have two questions regarding simple expressions:
1) Is it possible the get the time in miliseconds. Something like
${data:now.toMilli}
2) Is it possible to calculate with the simple language
${1 +1}
Kind regards,
Raymond