code: public static String timeToString(long time) {
          int[] fields = timeToFields(time, null);
          int millis = fields[5];
          int hour = millis / MILLIS_PER_HOUR;
          millis = millis % MILLIS_PER_HOUR;
          int min = millis / MILLIS_PER_MINUTE;
          millis = millis % MILLIS_PER_MINUTE;
          int sec = millis / MILLIS_PER_SECOND;
          millis = millis % MILLIS_PER_SECOND;
  
          return String.format((Locale)null, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
                  fields[0], fields[1] + 1, fields[2], hour, min, sec, millis);
      }
docs: Convenient method for formatting time to ISO 8601 style
  date string.
  @param time long time
  @return ISO-8601 date string