Have you ever tried to read an unformatted phone number? Reading a string of digits with no spaces or other delimiters is difficult. So much so that we tend to write them in a more digestible way. In North America, the common pattern is something like (xxx) xxx-xxxx. The punctuation varies, but the 3-3-4 grouping is pretty much universal. Other regions have their own patterns based on the number of digits they need to dial and how the area or city codes are allocated.

Given the number of countries in the world, coming up with display rules for each region is a daunting task. Luckily, some folks have already done this so you don’t need to reinvent the wheel. Libphonenmber handles display and validation of phone numbers, and looks to do a nice job of it. Check out the Libphonenumber Java demo if you need some convincing.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.