stoicflame / ofx4j

Apache License 2.0
75 stars 50 forks source link

BALAMT NumberFormatException #32

Closed evandrogrm closed 5 years ago

evandrogrm commented 5 years ago

When <BALAMT> TAG of LEDGERBAL contains comma throws a NumberFormatException, other values like TRNAMT do not Error: 11:40:27,126 ERROR [com.webcohesion.ofx4j.io.AggregateStackContentHandler] (default task-1) Unable to set element 'BALAMT' (property 'amount' of aggregate com.webcohesion.ofx4j.domain.data.common.BalanceInfo): java.lang.NumberFormatException: For input string: "-366622,72"

evandrogrm commented 5 years ago

I found the error, it's in DefaultStringConversion from Double type, changing

else if ((Double.class.isAssignableFrom(clazz)) || (Double.TYPE == clazz)) {
  return (E) new Double(Double.parseDouble(value));
}

to

else if ((Double.class.isAssignableFrom(clazz)) || (Double.TYPE == clazz)) {
  return (E) new Double(Double.parseDouble(value.replace(",", ".")));
}

Should fix it

stoicflame commented 5 years ago

If you put together a pull request for me, I'll merge it.

evandrogrm commented 5 years ago

I did it, I don't know how to merge it. #33

stoicflame commented 5 years ago

Fixed in 1.16.