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

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -