Java tutorial
//package com.java2s; public class Main { /** * * @param rawNumber * @return username - null if the number is invalid */ public static String generateUsernameFromPhoneNumber(String rawNumber) { int indexDoubleZero = rawNumber.indexOf("00"); String username = ""; if (indexDoubleZero == 0) { username = "p" + rawNumber.substring(2); } else if (rawNumber.charAt(0) == '+') { username = "p" + rawNumber.substring(1); } else if (rawNumber.charAt(0) == '0') { username = "p" + getCountryCode() + rawNumber.substring(1); } else { return null; } return username; } private static String getCountryCode() { // TODO method stub return "84"; //VN code } }