code: private Date readOptionalDate(JSONObject json, String key) {
  
          try {
              String str = json.getString(key);
              return new Date(Long.parseLong(str));
          } catch (NumberFormatException | JSONException e) {
              LOG.debug("Reading optional JSON Long failed. Default to provided default value.", e);
          }
          return null;
      }
docs: Read an optional Date value (stored as string) form a JSON Object.
  @param json the JSON object to read from.
  @param key the key for the Long value in the provided JSON object.
  @return the Date or null if reading the Date fails.