Formats the given epoch time in microseconds to typical human-readable format
"yyyy-MM-dd'T'HH:mm:ss.SSSX".

@param timeMicros epoch time in microseconds

@return the human readable string representation of the given epoch time
484620
public static StringBuilder epochMicro(long timeMicros) {
        // 24 (human readable part) + 2 (parens) + 19 (max digits of a long integer)
        final StringBuilder buf = new StringBuilder(45);
        appendEpochMicros(buf, timeMicros);
        return buf;
    }
206123
public static String format(Date time) {
        DateFormat timeFormat = new SimpleDateFormat(TimeField.FORMAT);
        return time == null ? null : timeFormat.format(time);
    }
968833
protected static function formatTime($time) {
        if ($time > 1000 && $time < 60000) {
            return sprintf('%02.2f', $time / 1000).'s';
        }

        if ($time > 60000) {
            return sprintf('%02.2f', $time / 60000).'m';
        }

        return sprintf('%02.2f', $time).'ms';
    }
457365
def get_readable_time_string(seconds):
    """"""
    seconds = int(seconds)
    minutes = seconds // 60
    seconds = seconds % 60
    hours = minutes // 60
    minutes = minutes % 60
    days = hours // 24
    hours = hours % 24

    result = ""
    if days > 0:
        result += "%d %s " % (days, "Day" if (days == 1) else "Days")
    if hours > 0:
        result += "%d %s " % (hours, "Hour" if (hours == 1) else "Hours")
    if minutes > 0:
        result += "%d %s " % (minutes, "Minute" if (minutes == 1) else "Minutes")
    if seconds > 0:
        result += "%d %s " % (seconds, "Second" if (seconds == 1) else "Seconds")

    return result.strip()
1005264
public static StringBuilder epochMillis(long timeMillis) {
        // 24 (human readable part) + 2 (parens) + 19 (max digits of a long integer)
        final StringBuilder buf = new StringBuilder(45);
        appendEpochMillis(buf, timeMillis);
        return buf;
    }
1341768
public static String asTime(long time) {
        if (time > HOUR) {
            return String.format("%.1f h", (time / HOUR));
        } else if (time > MINUTE) {
            return String.format("%.1f m", (time / MINUTE));
        } else if (time > SECOND) {
            return String.format("%.1f s", (time / SECOND));
        } else {
            return String.format("%d ms", time);
        }
    }
357250
public static DateTimeFormatter timeFormatterWithOptionalMilliseconds() {
        // This is the .SSS part
        DateTimeParser ms = new DateTimeFormatterBuilder()
                .appendLiteral(".")
                .appendFractionOfSecond(1, 3)
                .toParser();

        return new DateTimeFormatterBuilder()
                .append(DateTimeFormat.forPattern(ES_DATE_FORMAT_NO_MS).withZoneUTC())
                .appendOptional(ms)
                .toFormatter();
    }
975449
public static String formatDuration(long durationMs){
        Period period = Period.seconds((int)(durationMs/1000L));
        Period p2 = period.normalizedStandard(PeriodType.yearMonthDayTime());

        PeriodFormatter formatter = new PeriodFormatterBuilder()
                .appendYears()
                .appendSuffix(" yr ")
                .appendMonths()
                .appendSuffix(" months ")
                .appendDays()
                .appendSuffix(" days ")
                .appendHours()
                .appendSuffix(" hr ")
                .appendMinutes()
                .appendSuffix(" min ")
                .appendSeconds()
                .appendSuffix(" sec")
                .toFormatter();

        return formatter.print(p2);
    }
856055
public static String formatTimestamp(@Nullable Date date) {
        return (date != null) ? date.toInstant().toString() : null;
    }
1351263
public String formatTimeInterval(final long milliseconds) {
		long curMilliseconds = milliseconds;
		final StringBuilder sb = new StringBuilder().append("PT");
		final long hours = TimeUnit.MILLISECONDS.toHours(curMilliseconds);
		if (hours < 10)
			sb.append('0');
		sb.append(hours).append('H');
		curMilliseconds -= TimeUnit.HOURS.toMillis(hours);

		final long minutes = TimeUnit.MILLISECONDS.toMinutes(curMilliseconds);
		if (minutes < 10)
			sb.append('0');
		sb.append(minutes).append('M');
		curMilliseconds -= TimeUnit.MINUTES.toMillis(minutes);

		final long seconds = TimeUnit.MILLISECONDS.toSeconds(curMilliseconds);
		if (seconds < 10)
			sb.append('0');
		sb.append(seconds);
		curMilliseconds -= TimeUnit.SECONDS.toMillis(seconds);

		if (curMilliseconds > 0)
			sb.append('.').append(curMilliseconds);

		sb.append('S');
		return sb.toString();
	}
644350
def CopyToDateTimeString(self):
    
    if self._timestamp is None:
      return None

    number_of_days, hours, minutes, seconds = self._GetTimeValues(
        self._timestamp)

    year, month, day_of_month = self._GetDateValuesWithEpoch(
        number_of_days, self._EPOCH)

    return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}'.format(
        year, month, day_of_month, hours, minutes, seconds)
823070
public static String formatDuration(long durationInMs) {
    if (durationInMs < 1000) {
      return String.format("%sms", durationInMs);
    } else {
      long sec = durationInMs / 1000;
      if (sec < 60) {
        return String.format("%ss", sec);
      } else {
        long min = sec / 60;
        long remainingSec = sec - (min * 60);
        if (remainingSec > 0) {
          return String.format("%smin %ss", min, remainingSec);
        } else {
          return String.format("%smin", min);
        }
      }
    }
  }
857030
public static function formatTime($micros)
    {
        $seconds = $micros;
        $minutes = (int) floor($seconds / 60);
        if ($minutes >= 1) {
            return sprintf(
                "%1.0f minute%s %0.2f second%s",
                $minutes,
                ($minutes === 1 ? " " : "s "),
                $seconds - floor($seconds / 60) * 60,
                ($seconds % 60 === 1 ? "" : "s")
            );
        } else {
            return sprintf("%0.4f second%s", $seconds, ($seconds % 60 === 1 ? "" : "s"));
        }
    }
1366954
public static String getTimestamp(boolean withMsec) {
        return (withMsec ? SafeDateFormatter.getDateFormat(PATTERN_MSEC).format(new Date()) :
            SafeDateFormatter.getDateFormat(PATTERN).format(new Date()));
    }
1088676
def CopyToDateTimeString(self):
    
    if (self._timestamp is None or self._timestamp < 0 or
        self._timestamp > self._UINT64_MAX):
      return None

    timestamp, remainder = divmod(self._timestamp, self._100NS_PER_SECOND)
    number_of_days, hours, minutes, seconds = self._GetTimeValues(timestamp)

    year, month, day_of_month = self._GetDateValuesWithEpoch(
        number_of_days, self._EPOCH)

    return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:07d}'.format(
        year, month, day_of_month, hours, minutes, seconds, remainder)
1284255
def get_epoch_time_from_str(s):
    
    try:
        return int(s)
    except:
        pass

    try:
        if s.startswith('-'):
            chars = {'d': 24 * 60 * 60,
                     'h': 60 * 60,
                     'm': 60,
                     's': 1}
            m = chars.get(s[-1])
            if m:
                n = float(s[1:-1])
                secs = int(n * m)
                now = int(time.time())
                return max((now - secs), 0)
    except:
        pass

    raise ValueError("'%s' is an unrecognised time format." % s)
1072953
public function format_time( $seconds ) {
		$times = $this->friendly_times( $seconds );

		return sprintf( "%d:%02d:%02d", $times['hours'], $times['minutes'], $times['seconds'] );
	}