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!


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:

Leave a Reply

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

%d bloggers like this: