arrays - Format Phone Number Indentation using Java -


if have below 2 formats phone number in string array.

yyyxxxzzz , yyy-xxx-zzzz

and want normalize these phone numbers :

xxx-yyy-zzzz.

how can it?

just extract substrings based upon detected format.

if (!p.contains("-")) {   normalized = p.substring(3, 6) + "-" + p.substring(0, 3) + "-" + p.substring(6); } else {   normalized = p.substring(4, 7) + "-" + p.substring(0, 3) + "-" + p.substring(8); } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -