Class TelephoneNumberFormatter

java.lang.Object
com.portal.pfc.util.TelephoneNumberFormatter

public class TelephoneNumberFormatter extends Object
Class : TelephoneNumberFormatter Formats telephone number picking appropriate mask from the masks array. It provides a facility to truncate the telephone number to the length of the mask. Also the direction of formatting can be selected. In the mask any nonalphanumeric character can be the formatting character, and any alphanumeric character can represent the digits.
  • Method Details

    • format

      public static String format(String number, String[] maskArray)
      Formats telephone number. If masks array is empty, telephone number is returned without any formatting. The default mask is considered to be the first one in the masks array ( at index 0 ).Defaults: truncate and rightToLeft formatting are ON.
      Parameters:
      number - telephone number to be formatted
      maskArray - array of formatting masks
      Returns:
      String formatted telephone number
    • format

      public static String format(String number, String[] maskArray, Boolean truncate, Boolean rightToLeft)
      Formats telephone number. If masks array is empty, telephone number is returned without any formatting. The default mask is considered to be the first one in the masks array ( at index 0 ). This method is a wrapper around the method format(String number, String[] maskArray, boolean truncate, boolean rightToLeft)
      Parameters:
      number - telephone number to be formatted
      maskArray - array of formatting masks
      truncate - true if number needs to be truncated
      rightToLeft - true if the direction of formatting is Right to Left
      Returns:
      String formatted telephone number
    • format

      public static String format(String number, String[] maskArray, boolean truncate, boolean rightToLeft)
      Formats telephone number. If masks array is empty, telephone number is returned without any formatting. The default mask is considered to be the first one in the masks array ( at index 0 ).
      Parameters:
      number - telephone number to be formatted
      maskArray - array of formatting masks
      truncate - true if number needs to be truncated
      rightToLeft - true if the direction of formatting is Right to Left
      Returns:
      String formatted telephone number
    • normalize

      public static String normalize(String number)
      Normalizes number removing formatting characters
      Parameters:
      number - telephone number to be normalized
      Returns:
      String normalized telephone number