Bindy - Date Unmarshall Issue

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

Bindy - Date Unmarshall Issue

kc525
I ran into an issue with Apache Camel Bindy data format for the Date field parsing from a CSV file.

Date in the CSV : 02/11/2015 03:34:49 PM.

Format in the Bindy Class annotated as

@DataField(pos = 8,pattern="MM/dd/yyyy hh:mm:ss a")
private Date time;


Getting below exception

java.lang.IllegalArgumentException: Date provided does not fit the pattern defined, position: 8, line: 1 at org.apache.camel.dataformat.bindy.BindyCsvFactory.bind(BindyCsvFactory.java:213) at org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:185) at org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67)
It works if the date in the CSV is given as 2/11/2015 03:34:49 PM, with no preceeding 0 in the Month field.

I am using Camel 2.14.1.

Am I doing anything wrong here ? Please advise.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Bindy - Date Unmarshall Issue

Charles Moulliard-2
Hi,

Can you provide an example that we could test as the date pattern used
seems good. So, we should have a look to the code to see why it failed for
you.

Regards,


On Fri, Feb 20, 2015 at 2:00 AM, kc525 <[hidden email]>
wrote:

> I ran into an issue with Apache Camel Bindy data format for the Date field
> parsing from a CSV file.
>
> *Date in the CSV : 02/11/2015 03:34:49 PM.*
>
> Format in the Bindy Class annotated as
>
> *@DataField(pos = 8,pattern="MM/dd/yyyy hh:mm:ss a")
> private Date time;*
>
> Getting below exception
>
> java.lang.IllegalArgumentException: Date provided does not fit the pattern
> defined, position: 8, line: 1 at
>
> org.apache.camel.dataformat.bindy.BindyCsvFactory.bind(BindyCsvFactory.java:213)
> at
>
> org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:185)
> at
>
> org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67)
> It works if the date in the CSV is given as 2/11/2015 03:34:49 PM, with no
> preceeding 0 in the Month field.
>
> I am using Camel 2.14.1.
>
> Am I doing anything wrong here ? Please advise.
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Bindy-Date-Unmarshall-Issue-tp5762960.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
Reply | Threaded
Open this post in threaded view
|

Re: Bindy - Date Unmarshall Issue

Claus Ibsen-2
In reply to this post by kc525
Hi

It seems because bindy uses strict parsing by setting lenient = false

            df.setLenient(false);
            date = df.parse(string);

It should maybe not do that, and just use SimpleDataFormat parsing as
default out of the box.




On Fri, Feb 20, 2015 at 2:00 AM, kc525 <[hidden email]> wrote:

> I ran into an issue with Apache Camel Bindy data format for the Date field
> parsing from a CSV file.
>
> *Date in the CSV : 02/11/2015 03:34:49 PM.*
>
> Format in the Bindy Class annotated as
>
> *@DataField(pos = 8,pattern="MM/dd/yyyy hh:mm:ss a")
> private Date time;*
>
> Getting below exception
>
> java.lang.IllegalArgumentException: Date provided does not fit the pattern
> defined, position: 8, line: 1 at
> org.apache.camel.dataformat.bindy.BindyCsvFactory.bind(BindyCsvFactory.java:213)
> at
> org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:185)
> at
> org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67)
> It works if the date in the CSV is given as 2/11/2015 03:34:49 PM, with no
> preceeding 0 in the Month field.
>
> I am using Camel 2.14.1.
>
> Am I doing anything wrong here ? Please advise.
>
> Thanks.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Bindy-Date-Unmarshall-Issue-tp5762960.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/