You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Marco Zapletal <ma...@gmail.com> on 2013/07/29 13:50:10 UTC

Long <-> Date TypeConverter

Hi folks,


I recently encountered the situation that we required a Long (unix 
timestamp) to java.util.Date conversion. I was pretty sure that such a 
converter will exist in core-camel, but it doesn't. Furthermore, I came 
across some pieces of code in camel-core, where this conversion is done 
"manually" and not via a type converter - e.g., FileOperations:328

  Date date = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, 
Date.class);
             if (date != null) {
                 last = date.getTime();
             } else {
                 // fallback and try a long
                 last = 
exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);
  }


Is there a special reason why no Long <-> Date converter exists in the 
DateTimeConverter? If not, I would suggest to open a JIRA issue and 
attach a patch there.


Best regards,

Marco

Re: Long <-> Date TypeConverter

Posted by Christian Müller <ch...@gmail.com>.
Yeah, this could be a good improvement. As you know, we like contributions
[1]. Feel free to raise a JIRA and attach a patch.

[1] http://camel.apache.org/contributing.html

Best,
Christian
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Mon, Jul 29, 2013 at 1:50 PM, Marco Zapletal <ma...@gmail.com>wrote:

> Hi folks,
>
>
> I recently encountered the situation that we required a Long (unix
> timestamp) to java.util.Date conversion. I was pretty sure that such a
> converter will exist in core-camel, but it doesn't. Furthermore, I came
> across some pieces of code in camel-core, where this conversion is done
> "manually" and not via a type converter - e.g., FileOperations:328
>
>  Date date = exchange.getIn().getHeader(**Exchange.FILE_LAST_MODIFIED,
> Date.class);
>             if (date != null) {
>                 last = date.getTime();
>             } else {
>                 // fallback and try a long
>                 last = exchange.getIn().getHeader(**Exchange.FILE_LAST_MODIFIED,
> Long.class);
>  }
>
>
> Is there a special reason why no Long <-> Date converter exists in the
> DateTimeConverter? If not, I would suggest to open a JIRA issue and attach
> a patch there.
>
>
> Best regards,
>
> Marco
>