title: Java getTime() returns null from formatted String
body: <p>I have:</p>
  
  <pre><code>String stringDate = "2017-02-16T15:00:00Z"
  </code></pre>
  
  <p>I want to convert this into a Date and after it i want to be converted to Long. Here is my code:</p>
  
  <pre><code> private void normalizeDate(ContentValues values) {
      // normalize the date value
      if (values.containsKey(SmogContract.MeasurementEntry.COLUMN_FROM_DATE_TIME)) {
          Date date = convertDateFromStringToDate(values.getAsString(SmogContract.MeasurementEntry.COLUMN_FROM_DATE_TIME));
          long fromDateValue = date.getTime();
          values.put(SmogContract.MeasurementEntry.COLUMN_FROM_DATE_TIME, SmogContract.normalizeDate(fromDateValue));
      }
      if (values.containsKey(SmogContract.MeasurementEntry.COLUMN_TILL_DATE_TIME)) {
          long fromDateValue = values.getAsLong(SmogContract.MeasurementEntry.COLUMN_TILL_DATE_TIME);
          values.put(SmogContract.MeasurementEntry.COLUMN_TILL_DATE_TIME, SmogContract.normalizeDate(fromDateValue));
      }
  }
  
  private Date convertDateFromStringToDate(String stringDate){
      DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
      format.setTimeZone(TimeZone.getTimeZone("GMT"));
      Date convertedFromStringDate = null;
      try {
          convertedFromStringDate = format.parse(stringDate);
      } catch (ParseException e) {
          e.printStackTrace();
      }
  
      return convertedFromStringDate;
  }
  </code></pre>
  
  <p>Here is the exception that i am getting:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference
                   at com.example.marcin.smog_mapa.data.SmogProvider.normalizeDate(SmogProvider.java:109)
                   at com.example.marcin.smog_mapa.data.SmogProvider.insert(SmogProvider.java:85)
                   at android.content.ContentProvider$Transport.insert(ContentProvider.java:263)
                   at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:163)
                   at android.os.Binder.execTransact(Binder.java:453)
  </code></pre>