title: libphonenumber - formatting phone numbers without knowing the country code
body: <p>I have heard a lot of good from what appears to be an awesome library but I find myself in a delicate situation.</p>
  
  <p>This is the first project I have ever worked where I am supposed to store phone numbers in a database.</p>
  
  <p>I have read a bit about the <strong>E.164</strong> format and I do intend to store all phone numbers using this format in my database.</p>
  
  <p>The problem I am facing, is the data source. I have no control over the data source. All I known is that I am receiving a bunch of phone numbers and their format is not consistent. Some have the international extension, some don't. Some have parenthesis, hyphens, leading 0, etc. some don't.</p>
  
  <p>How could I possibly extract the phone numbers from said source, format them into E.164 so that I can store them safely ?</p>
  
  <p>I have tried using the <code>PhoneNumberUtil#parse()</code> method without providing the country code, since I don't have access to that information.</p>
  
  <p>Have a look at the following example:</p>
  
  <pre><code>System.out.printLn("Number -&gt; " + phoneNumberUtil.parse("00336555233634", null).toString())
  </code></pre>
  
  <blockquote>
    <p>Error type: INVALID_COUNTRY_CODE. Missing or invalid default region.</p>
  </blockquote>
  
  <p>In my example, the number is that of french mobile phone. The two starting <code>0</code> works if you dial from outside France, I believe.</p>
  
  <p>But the library cannot understand it as it is laking the country code.
  <strong>Does that mean there does not exist a way to understand where that particular phone number is coming from ?</strong></p>
  
  <p>The documentation seems clear about it :</p>
  
  <pre><code>public PhoneNumber parse(CharSequence numberToParse, String defaultRegion)
  </code></pre>
  
  <blockquote>
    <p>@param defaultRegion  region that we are expecting the number to be
    from. This is only used if    *     the number being parsed is not
    written in international format. The country_code for the    *<br>
    number in this case would be stored as that of the default region
    supplied. If the number    *     is guaranteed to start with a '+'
    followed by the country calling code, then RegionCode.ZZ    *     or
    null can be supplied.</p>
  </blockquote>
  
  <p>So, if add the <code>+33</code></p>
  
  <pre><code>System.out.printLn("Number -&gt; " + phoneNumberUtil.parse("+336555233634", null).toString())
  </code></pre>
  
  <p>Then naturally the result is:</p>
  
  <blockquote>
    <p>Number -> Country Code: 33 National Number: 336555233634</p>
  </blockquote>
  
  <p>What should / can I do if the end-user supplies my app with phone numbers that do not start with <code>+</code> ? I cannot believe I am the only one if this situation.</p>
  
  <p>Thanks for the help !</p>