title: How to convert an integer according to international number system in java (Number Formatting)
body: <p>I want to convert a given number according to international number system. // For example: </p>
  
  <pre><code>345678 -&gt; 345,678
  12 -&gt; 12 
  123 -&gt; 123
  4590 -&gt; 4,590
  </code></pre>
  
  <p>Here is the code snippet and <a href="http://ideone.com/ePiYPJ" rel="nofollow">IdeOne link</a></p>
  
  <pre><code>public static void main (String[] args) throws java.lang.Exception
  {
      int number = 345678;
      String s = Integer.toString(number);
      s = putCommas(s);
  }
  
  private String putCommas(String s) {
      // How to put commas in string after every 3rd character from right ?
  }
  </code></pre>
  
  <p>Here is my approach with which I am not comfortable.</p>
  
  <ol>
  <li>Start traversing string from right</li>
  <li>If the (length - currentIndex -1) % 3 == 0 insert comma in the string</li>
  </ol>
  
  <p>Any suggestions ?</p>