Here you can find the source of invertPhoneNumber(String storedNumber, String joinString)
public static String invertPhoneNumber(String storedNumber, String joinString)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static String invertPhoneNumber(String storedNumber, String joinString) { String prefix = String.join("", Arrays.asList("0", storedNumber.substring(2, 4))); String midnumbers, finalnumbers; try {//from ww w . j av a 2s .c o m midnumbers = storedNumber.substring(4, 7); finalnumbers = storedNumber.substring(7, 11); } catch (Exception e) { // in case the string doesn't have enough digits ... midnumbers = storedNumber.substring(4); finalnumbers = ""; } return String.join(joinString, Arrays.asList(prefix, midnumbers, finalnumbers)); } public static String invertPhoneNumber(String storedNumber) { return invertPhoneNumber(storedNumber, ""); } }