Java tutorial
//package com.java2s; public class Main { public static String formatPhone(String phone) { StringBuilder result = new StringBuilder(); if (phone != null && phone.length() == 11) { String prefix = "+86 "; result.append(prefix); result.append(phone.substring(0, 3)).append(" "); result.append(phone.substring(3, 7)).append(" "); result.append(phone.substring(7)); } return result.toString(); } }