title: How do format a phone number as a String in Java?
body: <p>I have been storing phone numbers as longs and I would like to simply add hyphens when printing the phone number as a string.</p>
  
  <p>I tried using <code>DecimalFormat</code> but that doesn't like the hyphen. Probably because it is meant for formatting decimal numbers and not longs.</p>
  
  <pre><code>long phoneFmt = 123456789L;
  DecimalFormat phoneFmt = new DecimalFormat("###-###-####");
  System.out.println(phoneFmt.format(phoneNum)); //doesn't work as I had hoped
  </code></pre>
  
  <p>Ideally, I would like to have parenthesis on the area code too.</p>
  
  <pre><code>new DecimalFormat("(###)-###-####");
  </code></pre>
  
  <p>What is the correct way to do this?</p>