You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by sergarci <se...@gmail.com> on 2014/05/19 13:54:39 UTC

Handle more than one csv file with two different date format

Hi there.

I'm currently working with Camel to parse some CSV files to java class using
bindy and camel-spring.

For every different file I need a separate route, because each file defines
a different model class.

The think is that, when I have two different format to parse Date from csv
to java class I have an error:

java.lang.IllegalArgumentException: Parsing error detected for field defined
at the position: ...

But when I runt each route separated it runs well.

I have defined the unmarshal like this:
<route ...
<unmarshal ref="bindyDataformat1" >
	<bindy type="Csv" classType="class1" />
</unmarshal>
</route>

<route ...
<unmarshal ref="bindyDataformat2" >
	<bindy type="Csv" classType="class2" />
</unmarshal>
</route>

And java class are like this:
@CsvRecord(separator = ",")
Class1{

    @DataField(pos = 5, pattern = "ddMMyyyy")
    private Date theDate;
...
@CsvRecord(separator = ",", skipFirstLine = true)
Class2{

    @DataField(pos = 2, pattern = "yyyy-MM-dd HH:mm:ss.SSS")
    private Date theDate;
...

Is there a known bug, how can I solve this issue?

Thank!



--
View this message in context: http://camel.465427.n5.nabble.com/Handle-more-than-one-csv-file-with-two-different-date-format-tp5751286.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Handle more than one csv file with two different date format

Posted by sergarci <se...@gmail.com>.
Thanks, I'll check BeanIO. For the moment I've solved with a custom CsvToBean
class.



--
View this message in context: http://camel.465427.n5.nabble.com/Handle-more-than-one-csv-file-with-two-different-date-format-tp5751286p5751403.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Handle more than one csv file with two different date format

Posted by "Walzer, Thomas" <th...@integratix.net>.
I know it´s a different avenue: but you could try BeanIO.
Should be doable.

Cheers, Thomas.

Am 19.05.2014 um 13:54 schrieb sergarci <se...@gmail.com>:

> Hi there.
> 
> I'm currently working with Camel to parse some CSV files to java class using
> bindy and camel-spring.
> 
> For every different file I need a separate route, because each file defines
> a different model class.
> 
> The think is that, when I have two different format to parse Date from csv
> to java class I have an error:
> 
> java.lang.IllegalArgumentException: Parsing error detected for field defined
> at the position: ...
> 
> But when I runt each route separated it runs well.
> 
> I have defined the unmarshal like this:
> <route ...
> <unmarshal ref="bindyDataformat1" >
> 	<bindy type="Csv" classType="class1" />
> </unmarshal>
> </route>
> 
> <route ...
> <unmarshal ref="bindyDataformat2" >
> 	<bindy type="Csv" classType="class2" />
> </unmarshal>
> </route>
> 
> And java class are like this:
> @CsvRecord(separator = ",")
> Class1{
> 
>    @DataField(pos = 5, pattern = "ddMMyyyy")
>    private Date theDate;
> ...
> @CsvRecord(separator = ",", skipFirstLine = true)
> Class2{
> 
>    @DataField(pos = 2, pattern = "yyyy-MM-dd HH:mm:ss.SSS")
>    private Date theDate;
> ...
> 
> Is there a known bug, how can I solve this issue?
> 
> Thank!
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Handle-more-than-one-csv-file-with-two-different-date-format-tp5751286.html
> Sent from the Camel - Users mailing list archive at Nabble.com.