apache-camelbindy

Need to convert String to Float variable using Camel-Bindy Format


A test file with delimited Data and one of the field is amount and it arrives as a string. To be converted to float. As per camel-bindy i tried a way, but ended with same value without precesions. Input : 12345678

@DataField(name="AMT", trim=true, pos = 15 , precision=2) private BigDecimal amount;

Route: .unmarshal().bindy(BindyType.Csv, Test.class)

O/P: 12345678.00

Its not getting converted to 123456.78

Please help me with any suggestions.


Solution

  • Annotation @DataField provides another method implementation which supports this kind of feature,

    @DataField(name="AMT", trim=true, pos = 15 , precision=2, impliedDecimalSeparator = true) private BigDecimal amount;

    impliedDecimalSeparator decides the decimal position for incoming string field and converts as required.