title: Integer.parseInt throws NumberFormatException?
body: <p>I am using a Datepicker in my application. What I am trying to do is getting the date already set in the text field and showing that on Datepicker control. But I am getting NumberFormatException when I use</p>
  
  <pre><code>Integer.parseInt(splittedDate[2])  //i.e the year column. 
  </code></pre>
  
  <p>When I see while debugging splittedDate containf three values which are fine. but while parsing year column at last index throws exception. I am unable to understand why is it so. pleasehelp me out of this. Following is the implementation of CreateDialog method for Datepicker.</p>
  
  <pre><code>@Override
  protected Dialog onCreateDialog(int id) {
      if (id == DATE_DIALOG_ID) {
          if (birthDate.getText().toString().equalsIgnoreCase(""))
              return new DatePickerDialog(this, mDateSetListener, mYear,
                      mMonth, mDay);
          else {
              String[] splittedDate = birthDate.getText().toString().split("-");
  
              try{
  
                  Log.i("Month String", splittedDate[0]);
                  mMonth = Integer.parseInt(splittedDate[0]);
                  Log.i("Day String", splittedDate[1]);
                  mDay = Integer.parseInt(splittedDate[1]);
                  Log.i("Year String", splittedDate[0]);
                  mYear = Integer.parseInt(splittedDate[2]);
  
              }
              catch(Exception e)
              {
                  Log.e("Number Format Exception Message: ",e.getMessage());
              }
  
              return new DatePickerDialog(this, mDateSetListener, mYear,
                      mMonth, mDay);
  
          }
  
      return null;
  }
  </code></pre>
  
  <p>Here is the logCat info:</p>
  
  <pre><code> 09-05 16:21:54.722: E/AndroidRuntime(28596): FATAL EXCEPTION: main
   09-05 16:21:54.722: E/AndroidRuntime(28596): java.lang.NumberFormatException: unable to parse '1970 ' as integer
   09-05 16:21:54.722: E/AndroidRuntime(28596):   at java.lang.Integer.parse(Integer.java:383)
   09-05 16:21:54.722: E/AndroidRuntime(28596):   at java.lang.Integer.parseInt(Integer.java:372)
   09-05 16:21:54.722: E/AndroidRuntime(28596):   at java.lang.Integer.parseInt(Integer.java:332)
   09-05 16:21:54.722: E/AndroidRuntime(28596):   at com.test.project.activity.DetailActivity.onCreateDialog(DetailActivity.java:332)
  </code></pre>