title: How to solve the error for DecimalFormat on a calculator app
body: <p>I am making a calculator app.</p>
  <p><code>workingsTV</code> is the place where calculating is shown.</p>
  <p><code>resultsTV</code> is the place showing the result of calculating.</p>
  <p><code>workings</code> is doing math by using rhino's library.</p>
  <p>I want to add a comma at every three digits on both <code>workingsTV</code> and <code>resultsTV</code>.</p>
  <p>I tried to use it like this for <code>resultsTV</code>.</p>
  <pre><code> DecimalFormat df = new DecimalFormat(&quot;###,###.####&quot;, new DecimalFormatSymbols(Locale.US));
                  result = Double.parseDouble(df.format(result));
  </code></pre>
  <p>But then the app was closed when to show <code>result</code></p>
  <p>This is the error message
  <br>Caused by: java.lang.reflect.InvocationTargetException
  <br>Caused by: java.lang.NumberFormatException: For input string: &quot;1,235&quot;</p>
  <p><strong>Here is the top part of the code</strong></p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      TextView workingsTV;
      TextView resultsTV;
  
      String workings = &quot;&quot;;
      String CLEAR_INT_TEXT;
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          initTextView();
      }
  
  
  
      private void initTextView()
      {
          workingsTV = (TextView)findViewById(R.id.workingsTextView);
          resultsTV = (TextView)findViewById(R.id.resultTextView);
      }
  
      private void setWorkings(String givenValue)
      {
          workings = workings + givenValue;
          workingsTV.setText(workings);
  
      }
  
  
      public void equalsOnClick(View view)
      {
          Double result = null;
          ScriptEngine engine = new ScriptEngineManager().getEngineByName(&quot;rhino&quot;);
  
          try {
              result = (Double) engine.eval(workings);
              if (result != null)
              {
  
                  DecimalFormat df = new DecimalFormat(&quot;###,###.####&quot;, new DecimalFormatSymbols(Locale.US));
                  result = Double.parseDouble(df.format(result));
  
  
                  int intVal = (int) result.doubleValue();
                  if (result == intVal)
                  {//Check if it's value is equal to its integer part
                      resultsTV.setText(String.valueOf(intVal));
                  }
                  else
                  {
                      resultsTV.setText(String.valueOf(result));
                  }
              }
          }
  </code></pre>