We work with a vendor that sends us various different XML messages that we need to process.
For values such as price, sometimes they send us the number in this format – 123.45
When we run the code BigDecimal bd = new BigDecimal("123.45");, it works fine
Unfortunately, they sometimes send us the number in this format – 123,45
When we run the code BigDecimal bd = new BigDecimal("123,45");, we get a NumberFormatException
Does anyone know of an API that can accept a string that contains a . or a , and can convert it to a BigDecimal or will we need to do a String replace first and convert all instances of , to .?
Thanks
Yes your second point is reasonably usable. You are not provided with such a function that converts a number( actually it becomes a string when a ‘,’ is used with it) that is not actually a number. Whereas only periods are allowed in a float.