user2250482
user2250482

Reputation: 75

Selenium how to convert the String data of 'say' 2000.0 to convert to 2000 and remove the floating point and trailing zeros

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

Answers (3)

SATENDRA
SATENDRA

Reputation: 105

You can also implement this -

String data = "2000.0";
int i = Integer.parseInt(data);

Upvotes: 0

Prash
Prash

Reputation: 39

You can do this:

    String data = "2000.0";
    int i = (int)Double.parseDouble(data);

Upvotes: 0

Lajos Arpad
Lajos Arpad

Reputation: 76464

(long)Double.parseDouble("2000.0");

It first converts the String to double and then converts it to long.

Upvotes: 1

Related Questions