I'm using Selenium WebDriver
(Java) and passing the String
value that has decimal point and leading zero. I want to remove it. This is what I'm trying but doesn't work:
String data=2000.0
Long.parseLong(data);
(long)Double.parseDouble("2000.0");
它首先将String转换为double,然后将其转换为long。
You can do this:
String data = "2000.0";
int i = (int)Double.parseDouble(data);
You can also implement this -
String data = "2000.0";
int i = Integer.parseInt(data);
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.