Java: Format a string as a telephone number
<p>I have an unformatted telephone number string ("5551234567"). I would like to format this string for display purposes in the ui. The number should look like this after format: </p>

<p>(555) 123-4567</p>

<p>Sigh.....</p>

<p>I was trying to find a generic way that would take into account both US and international phone numbers. I came accross the MaskFormatter in the JDK but discovered that there is a bug in the Javadoc. Which lead me to asking my question here. I was hoping for a solution where I could input a mask then the actual string. The output would be formatted accordingly for international/US numbers or if the wrong number of characters were specified, some default character would be displayed in place of the missing characters........</p>

<p><a href="http://www.java.net/node/660119" rel="nofollow">http://www.java.net/node/660119</a></p>
