I have number eleven digit number from my DB: 12345678910 I need to get this number in the following format: 123-456-789-10 How i can get it with standart Java?
You can use a StringBuilder
:
long number = 12345678910L;
String stringNumber = new StringBuilder(number + "")
.insert(3, '-')
.insert(7, '-')
.insert(11, '-')
.toString();