Here you can find the source of formatPhoneNo(String country, String area, String number, String inline)
public static String formatPhoneNo(String country, String area, String number, String inline)
//package com.java2s; public class Main { public static String formatPhoneNo(String country, String area, String number, String inline) { StringBuffer sb = new StringBuffer(); boolean first = true; if (country != null) country = country.trim();//from w ww . j a v a2s.co m if (area != null) area = area.trim(); if (number != null) number = number.trim(); if (inline != null) inline = inline.trim(); //if (JFCheck.isEmpty(country) == false) { if ((country != null) && !country.trim().equals("")) { sb.append(country); first = false; } //if (JFCheck.isEmpty(area) == false) { if ((area != null) && !area.trim().equals("")) { if (first == false) sb.append("-"); sb.append(area); first = false; } //if (JFCheck.isEmpty(number) == false) { if ((number != null) && !number.trim().equals("")) { if (first == false) sb.append("-"); if (number.length() > 4) { sb.append(number.substring(0, number.length() - 4)); sb.append("-"); sb.append(number.substring(number.length() - 4)); } else { sb.append(number); } first = false; } //if (JFCheck.isEmpty(inline) == false) { if ((inline != null) && !inline.trim().equals("")) { sb.append("(" + inline + ")"); } return sb.toString(); } }