Reputation: 75
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);
Upvotes: 1
Views: 4723
Reputation: 105
You can also implement this -
String data = "2000.0";
int i = Integer.parseInt(data);
Upvotes: 0
Reputation: 39
You can do this:
String data = "2000.0";
int i = (int)Double.parseDouble(data);
Upvotes: 0
Reputation: 76464
(long)Double.parseDouble("2000.0");
It first converts the String to double and then converts it to long.
Upvotes: 1