简体   繁体   中英

Parsing a String to 2 Decimal Places to Double

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM