camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Re: Camel Bindy: parse a BigDecimal number with a given pattern
Date Wed, 20 Aug 2014 18:39:24 GMT
The numbers I'd like to parse could have one the following structures:

(there are several rows in one file so it is possible that different structures appear in
a file)

Setting the precision already works fine and the decimal separator is treated correctly.
The current problem is that I can't tell bindy to ignore the comma sings in every number,
because they are for grouping purposes and not needed in the BigDecimal field.

If I keep the comma sign in these numbers the parsing process will raise a NumberFormatException
mentioning a malformed number. If I remove that comma signs in a test file, everything works
fine and the number
is mapped to the datafield correctly, but sadly that can't be a solution, because this csv
files are provided by
different system that cannot be changed.

If I use the following annotation
@DataField(pos = 2, precision = 2, pattern = "#,###.##")
and use Double instead of BigDecimal I can keep the comma sings. But I can't use Double for
several reasons.

The source code of the FormatFactory class (version 2.13.1) that I linked in my question also
shows that the pattern is used for Double types (and several other types) but not for BigDecimal

-----Urspr√ľngliche Nachricht-----
Gesendet: Wednesday, 20 August 2014 um 19:33:05 Uhr
Von: "Charles Moulliard" <>
Betreff: Re: Camel Bindy: parse a BigDecimal number with a given pattern
The @DataField of Camel bindy proposes the parameter precision like also a
pattern but not a grouping separator


    @DataField(pos = 2, precision = 2, pattern = "00.00")
    private BigDecimal bigDecimal;

Do you have an example to propose about such use case ?

On Wed, Aug 20, 2014 at 3:43 PM, <> wrote:

> Hello,
> I currently have a problem concerning Camel Bindy. I have a csv file that
> should be parsed with Camel Bindy using a given model class. This csv file
> contains a number that should be parsed as a BigDecimal. The problem is
> that
> this number contains a comma as a grouping separator and a point as the
> decimal separator.
> If I start the camel route the unmarshal process will throw a
> NumberFormatException mentioning the invalid format of that number. So I
> tried to add a pattern to the DataField annotation, but the error stays.
> After digging throw the documentation (
> and the source code of FormatFactory
> (
> )
> I'm a little bit confused, because the documentation mentions the ability
> to
> specify a grouping separator, but the source code shows that the pattern is
> ignored for BigDecimal data types.
> Does anyone know how to specify that grouping separator? Or is this not
> implemented yet?
> Many thanks in advance.
> Best regards.
> Tom
> P.S. I also posted that question on stackoverflow
> (
> ),
> but with no luck yet.
> P.P.S. I posted that question using (
> some moments
> ago, but it seems that there is a problem with my mail provider that
> doesn't allow services like this. So I'm sending this question directly
> now. Sorry for any inconveniences.

Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :

View raw message