Issue
I have a x-path
in selenium which contains dynamic value as p01 to p15. If So, if I increment it should pass like 02,03,04,05,06,07,08,09,10,11,12 like this.
But i am unable to find a code to increment a value with 0 prefix.
Solution
I'm not sure the complete nature of the request because there is some information missing but you can adding leading zeroes to an integer in java with String format.
public class Main {
public static void main(String[] args) {
String formatted = String.format("%02d", 5);
String formatted1 = String.format("%02d", 11);
System.out.println(formatted);
}
}
Add leading zeroes to number in Java?
Answered By - Sam Orozco
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.