0

Here's my String

37900

That I receive through an API.

However the real value of that item in double is 379.00

Also there might items that can be in the same format as that. so let's say

120000, the real value of this one is 1200.00

How do I parse it like that?

user962206
  • 15,637
  • 61
  • 177
  • 270
  • 2
    Why not just `parseDouble(str) / 100`? – Cinnam Oct 31 '15 at 00:58
  • But be aware of [this issue](http://stackoverflow.com/questions/153724/how-to-round-a-number-to-n-decimal-places-in-java/12684082#12684082). If this is money it should be stored in a `BigDecimal`. – user207421 Dec 04 '16 at 06:38

1 Answers1

1
String numberAsString = "15,000";
double number = Double.parseDouble(numberAsString);
number = number/100;

Here is the String to double. Then dividing it to the format you want.

user207421
  • 305,947
  • 44
  • 307
  • 483
LearningProcess
  • 607
  • 1
  • 8
  • 29