Menu

#39 Thousands separator for North European numbers

2.2.0
closed
None
1
2014-04-24
2013-10-06
Olaf Thiele
No

ParseBigDecimal can be given a DecimalFormatSymbols when processing a European number like 23,0 so it is transformed to 23.0. But when the number contains a thousands separator like 200.000,00 it throws an error. This is due to the fact that the ',' is replaced by '.' but not the thousands separator.

A good solution would be to simply delete '.' in the String when handling North European numbers.

Discussion

  • Egga Hartung

    Egga Hartung - 2014-04-23

    here is a patch that could do the trick. notes:

    • i couldn't find out how to contribute other than attaching a patch here. point me anywhere, i will happily do whatever is needed.
    • it should be compatible with java 1.5, right? i need to have a second look, if that is the case with the patch.
    • french symbols apparently don't have a grouping separator. so i changed the tests to germany, which has the same decimal sep as france.
    • my ide changed more whitespace than wanted. i can take a second run with less changes, if desired.
     
  • James Bassett

    James Bassett - 2014-04-24

    Awesome thanks Jan :) This change has been committed.

    I made a few really minor changes, including refactoring ParseBigDecimal to use the DecimalFormatSymbols as a field (instead of each separate symbol) - just in case there's any other need to 'fix' the data in the future based on other symbols.

    I've added your name to the list of contributors, and I'll try and get a release out soon (I can't believe it's been a year...oh the shame!).

    Cheers,
    James

     
  • James Bassett

    James Bassett - 2014-04-24
    • status: open --> pending
    • assigned_to: James Bassett
    • Group: Outstanding --> 2.2.0
     
  • James Bassett

    James Bassett - 2014-04-24

    Fixed in [r297]

     

    Related

    Commit: [r297]

  • Olaf Thiele

    Olaf Thiele - 2014-04-24

    Thanks for fixing that, now I can upgrade to a future version without the need to carry on hacking the input.

     
  • Egga Hartung

    Egga Hartung - 2014-04-24

    Yay, what a day \o/

    I considered saving the symbols object as a property, but thought that may slow down the parsing.

    Thanks James!

     
  • James Bassett

    James Bassett - 2014-04-24
    • Status: pending --> closed
     
  • James Bassett

    James Bassett - 2014-04-24

    Woo it's released! Good job everyone :P

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.