I have the following string:
String x = "020120765";
I want this string in the form of 02 0120765. One possibility is:
x = x.substring(0,2) + " " + x.substring(2, x.length());
or:
x = String.format("%s %s", x.substring(0, 2), x.substring(2));
Is there any other better or elegant way? I'm thinking in the direction of regex. I have tried the following:
x = String.format("%s %s", x.split("\\d{2}"));
But it doesn't work.
x.length()as the second argument tosubstring, and just writex.substring(2)