Code example for SimpleDateFormat

Methods: format

0
   
  public String getFileInfoString() {
    int appSize = failSafeGetIntFromJSON(newest, "appsize", 0);
    long timestamp = failSafeGetIntFromJSON(newest, "timestamp", 0);
    Date date = new Date(timestamp * 1000);
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
    return dateFormat.format(date) + " - " + String.format("%.2f", appSize / 1024F / 1024F) + " MB";
  } 
   
  private static String failSafeGetStringFromJSON(JSONObject json, String name, String defaultValue) {
    try { 
      return json.getString(name);
    } 
    catch (JSONException e) {
      return defaultValue;
    } 
  } 
   
  private static int failSafeGetIntFromJSON(JSONObject json, String name, int defaultValue) {
    try { 
      return json.getInt(name);