convert time from long to formatted string.

@param time
@return
10525
private String convertTime(final long time) {
    final Date date = new Date(time);
    return FORMAT.format(date);
  }
1241277
public static String timeToString(long time) {

        time += DATE_SHIFT;


        if (time < 0) {
            throw new IllegalArgumentException("time too early");
        }

        String s = Long.toString(time, Character.MAX_RADIX);

        if (s.length() > DATE_LEN) {
            throw new IllegalArgumentException("time too late");
        }

        // Pad with leading zeros
        if (s.length() < DATE_LEN) {
            StringBuilder sb = new StringBuilder(s);
            while (sb.length() < DATE_LEN) {
                sb.insert(0, 0);
            }
            s = sb.toString();
        }

        return s;
    }
1165276
public static Date strToTime(String time) throws ParseException {

        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyyMMdd:HH");

        java.util.Date d = sdf.parse(time);

        return d;
    }
936040
private static String formatTime(int length, long time) {
        Calendar cal = Calendar.getInstance();
        if (time > -1) cal.setTimeInMillis(time);
        StringBuilder sb = new StringBuilder(length);
        int month = cal.get(Calendar.MONTH) + 1;
        int day = cal.get(Calendar.DAY_OF_MONTH);
        int hour = cal.get(Calendar.HOUR_OF_DAY);
        int minute = cal.get(Calendar.MINUTE);
        int seconds = cal.get(Calendar.SECOND);
        sb.append(cal.get(Calendar.YEAR)).append('-');
        if (month < 10) sb.append('0');
        sb.append(month).append('-');
        if (day < 10) sb.append('0');
        sb.append(day).append(' ');
        if (hour < 10) sb.append('0');
        sb.append(hour).append(':');
        if (minute < 10) sb.append('0');
        sb.append(minute).append(':');
        if (seconds < 10) sb.append('0');
        sb.append(seconds);
        if (length > 20) {
            int millis = cal.get(Calendar.MILLISECOND);
            sb.append('.');
            if (millis < 10) {
                sb.append("00");
            } else if (millis < 100) {
                sb.append('0');
            }
            sb.append(millis);
        }
        return sb.toString();
    }
47647
protected long convertDurationString(String duration) {
		final Matcher m = DURATION_STRING_PATTERN.matcher(duration);
		if (!m.matches()) {
			throw new IllegalArgumentException("Invalid duration string format");
		}

		final long sourceDuration = Long.parseLong(m.group(1));
		final String sourceUnitString = m.group(2);
		final TimeUnit sourceUnit;
		if ("ns".equalsIgnoreCase(sourceUnitString)) {
			sourceUnit = TimeUnit.NANOSECONDS;
		}
		else if ("us".equalsIgnoreCase(sourceUnitString)) {
			sourceUnit = TimeUnit.MICROSECONDS;
		}
		else if ("ms".equalsIgnoreCase(sourceUnitString)) {
			sourceUnit = TimeUnit.MILLISECONDS;
		}
		else if ("s".equalsIgnoreCase(sourceUnitString)) {
			sourceUnit = TimeUnit.SECONDS;
		}
		else if ("m".equalsIgnoreCase(sourceUnitString)) {
			sourceUnit = TimeUnit.MINUTES;
		}
		else if ("h".equalsIgnoreCase(sourceUnitString)) {
			sourceUnit = TimeUnit.HOURS;
		}
		else if ("d".equalsIgnoreCase(sourceUnitString)) {
			sourceUnit = TimeUnit.DAYS;
		}
		else {
			sourceUnit = TimeUnit.MILLISECONDS;
		}

		return sourceUnit.toNanos(sourceDuration);
	}
1343856
def time_to_text(time):
    """"""
    
    if time < 0.001:
        return str(round(time * 1000000)) + " µs"
    elif time < 1:
        return str(round(time * 1000)) + " ms"
    elif time < 60:
        return str(round(time, 1)) + " s"
    else:
        return str(round(time / 60, 1)) + " min"
416318
public static String formatTimeSec(long time) {

        StringBuffer str = new StringBuffer();

        if (time < 60) {
            str.append(time + " sec");
            return str.toString();
        }

        int days = (int) time / 86400;

        if (days != 0) {
            str.append(days + " days");
            time -= days * 86400;
        }

        int hours = (int) time / 3600;

        if (hours != 0) {
            if (str.length() != 0) str.append(", ");
            str.append(hours + " h");
            time -= hours * 3600;
        }

        int mins  = (int) time / 60;

        if (mins != 0) {
            if (str.length() != 0) str.append(", ");
            str.append(mins + " min");
            time -= mins * 60;
        }

        int sec   = (int) time;

        if (sec != 0) {
            if (str.length() != 0) str.append(", ");
            str.append(sec + " sec");
        }

        return str.toString();
    }
89749
public static long parseTimeString( String time ) {
        String trimmed = time.trim();
        long result = 0;
        if( trimmed.length() > 0 ) {
            Matcher mat = SIMPLE.matcher( trimmed );
            if ( mat.matches() ) {
                int days = (mat.group( SIM_DAY ) != null) ? Integer.parseInt( mat.group( SIM_DAY ) ) : 0;
                int hours = (mat.group( SIM_HOU ) != null) ? Integer.parseInt( mat.group( SIM_HOU ) ) : 0;
                int min = (mat.group( SIM_MIN ) != null) ? Integer.parseInt( mat.group( SIM_MIN ) ) : 0;
                int sec = (mat.group( SIM_SEC ) != null) ? Integer.parseInt( mat.group( SIM_SEC ) ) : 0;
                int ms = (mat.group( SIM_MS ) != null) ? Integer.parseInt( mat.group( SIM_MS ) ) : 0;
                long r = days * DAY_MS + hours * HOU_MS + min * MIN_MS + sec * SEC_MS + ms;
                if( mat.group(SIM_SGN) != null && mat.group( SIM_SGN ).equals( "-" ) ) {
                    r = -r;
                }
                result = r;
            } else if( "*".equals( trimmed ) || "+*".equals( trimmed ) ) {
                // positive infinity
                result = Long.MAX_VALUE;
            } else if( "-*".equals( trimmed ) ) {
                // negative infinity
                result = Long.MIN_VALUE;
            } else {
                throw new RuntimeException( "Error parsing time string: [ " + time + " ]" );
            }
        }
        return result;
    }
1322680
public String toTimeStr() {
		if (null != this.timeZone) {
			final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DatePattern.NORM_TIME_PATTERN);
			simpleDateFormat.setTimeZone(this.timeZone);
			return toString(simpleDateFormat);
		}
		return toString(DatePattern.NORM_TIME_FORMAT);
	}
233124
public static String toDuration(long inputTime) {
    final long second = 1000000000L;
    final long minute = 60 * second;
    final long hour = 60 * minute;
    final long day = 24 * hour;
    final long week = 7 * day;

    long time = inputTime;
    final StringBuilder buf = new StringBuilder();
    buf.append('P');
    time = append(buf, 'W', week, time);
    time = append(buf, 'D', day, time);
    buf.append('T');
    time = append(buf, 'H', hour, time);
    time = append(buf, 'M', minute, time);
    append(buf, 'S', second, time);
    return buf.toString();
  }
544851
function formatTime(time) {
  let date = new Date(time);

  return (date.getFullYear() + '-' +
    zeroPad(date.getMonth() + 1) + '-' +
    zeroPad(date.getDate()) + ' ' +
    zeroPad(date.getHours()) + ':' +
    zeroPad(date.getMinutes()) + ':' +
    zeroPad(date.getSeconds()));

  function zeroPad(num) {
    return ('0' + num).slice(-2)
  }
}
662283
public static String durationToFormattedString(final Duration duration) {
        if (duration == null) {
            return null;
        }

        return LocalTime.ofNanoOfDay(duration.toNanos()).format(DateTimeFormatter.ofPattern(DURATION_FORMAT));
    }
617674
public String format(Time pTime) {
	StringBuilder buf = new StringBuilder();
	for (int i = 0; i < formatter.length; i++) {
	    buf.append(formatter[i].format(pTime));
	}
	return buf.toString();
    }
558210
public String getDate(long time) {

        return CmsDateUtil.getDate(new Date(time), DateFormat.SHORT, m_locale);
    }
472989
public static String getTimestamp(Date time) {
        return getTimestampFormatter().format(time == null ? new Date() : time);
    }
257183
public String getDateTime(long time) {

        return CmsDateUtil.getDateTime(new Date(time), DateFormat.SHORT, m_locale);
    }
840043
public static String toTimeString(java.util.Date date) {
		if (date == null)
			return "";
		Calendar calendar = Calendar.getInstance();

		calendar.setTime(date);
		return (toTimeString(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND)));
	}