List of utility methods to do Milliseconds
long | timeSinceMillis(long timestart) Time elapsed since a start time. return (timeSince(timestart) / 1000000);
|
long | timespanToMillis(String timeString) timespan To Millis Pattern pattern = Pattern.compile("(-?\\d+\\.?\\d*)([\\w]{0,1})", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(timeString); if (matcher.matches()) { double baseMillis = Double.parseDouble(matcher.group(1)); String unit = matcher.group(2).toLowerCase(); if (unit.equals("d") || unit.length() == 0) { return (long) (baseMillis * 1000 * 3600 * 24); } else if (unit.equals("h")) { ... |
String | timestampToString(long lastModifiedMillis) timestamp To String Date date = new Date(lastModifiedMillis); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); return format.format(date); |
long | timeToMilliseconds(Object unit, long interval) time To Milliseconds switch (unit.toString()) { case "SECONDS": return interval * 1000L; case "MINUTES": return interval * 1000L * 60L; case "HOURS": return interval * 1000L * 60L * 60L; case "DAYS": ... |
String | timeToString(long timeMillis) Returns a String representation of the time. DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); return dateFormat.format(new Date(timeMillis)); |
String | timeToTag(long milliSeconds) time To Tag SimpleDateFormat sdf = new SimpleDateFormat("mm:ss.SS"); Date d = new Date(milliSeconds); String text = sdf.format(d); text = text.substring(0, text.length() - 1); return text; |
long | toMillis(String ts) convert timestamp to millis Date dts = toDate(ts);
return dts.getTime();
|
String | toSpacelessDateString(long millisSinceEpoch) to Spaceless Date String SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HHmmss", Locale.US); Date t = new Date(millisSinceEpoch); return sdf.format(t); |
String | ToSting(Long milliSecond) To Sting SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(milliSecond); |
String | toTime(long milli) to Time Calendar date = Calendar.getInstance(); date.setTimeInMillis(milli); DateFormat format = new SimpleDateFormat("HH:mm:ss"); return format.format(date.getTime()); |