code: public static String formatDate(long time) {
          // Map date/time to a GregorianCalendar object (local time zone).
          GregorianCalendar date = new GregorianCalendar();
          date.setTimeInMillis(time);
          return formatDate(date, Calendar.SECOND);
      }
docs: Format a Date.getTime() value as "YYYY-MM-DD HH:mm:ss". This method creates a
  GregorianCalendar object using the <i>local</i> time zone and then calls
  {@link #formatDate(Calendar)}.
  
  @param   time    Date/time in Date.getTime() format (milliseconds since the epoch).
  @return          "YYYY-MM-DD HH:mm:ss".