You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kc525 <ki...@gmail.com> on 2015/02/20 02:00:54 UTC

Bindy - Date Unmarshall Issue

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.

Re: Bindy - Date Unmarshall Issue

Posted by Claus Ibsen <cl...@gmail.com>.
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 <ki...@gmail.com> 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: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Bindy - Date Unmarshall Issue

Posted by Charles Moulliard <ch...@gmail.com>.
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 <ki...@gmail.com>
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