Laurent Hinoul

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - John F. Woods

How to change phone number layout with Java

Each country has its own phone number format. But what if you want a universal layout for all types of phone numbers? You can use Libphonenumber. With Libphonenumber, you can change phone layouts, create your own layouts, cast layouts and many more!

Maven:

As example we take a phone number:

We will change that layout to a Swiss layout:

Full code:

You can also choose other layouts:

You can change the layout to other country layouts:

Libphonenumber gives you the opportunity to create your own layout:

You can get a phone number layout by using Locale:

For more information: http://code.google.com/p/libphonenumber/

Leave a Reply