Package com.portal.pfc.util
Class TelephoneNumberFormatter
java.lang.Object
com.portal.pfc.util.TelephoneNumberFormatter
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
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 formattedmaskArray
- 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 formattedmaskArray
- array of formatting maskstruncate
- true if number needs to be truncatedrightToLeft
- 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 formattedmaskArray
- array of formatting maskstruncate
- true if number needs to be truncatedrightToLeft
- true if the direction of formatting is Right to Left- Returns:
- String formatted telephone number
-
normalize
Normalizes number removing formatting characters- Parameters:
number
- telephone number to be normalized- Returns:
- String normalized telephone number
-