Java phone number format API

You could write your own (for US phone # format):

  • Strip any non-numeric characters from the string
  • Check that the remaining string is ten characters long
  • Put parentheses around the first three characters and a dash between the sixth and seventh character.
  • Prepend “+1 ” to the string

Update:

Google recently released libphonenumber for parsing, formatting, storing and validating international phone numbers.

Leave a Comment