List of utility methods to do Milliseconds
void | marsTimeFromElapsedMillis(long elapsedMillis, int[] marsTime) Calculate the local Mars time from the number of milliseconds since the start of Sol 1. double marsDaySecs = (double) 35.244 + (double) 24 * 60 * 60 + 39 * 60; double solDouble = ((double) (elapsedMillis / 1000)) / marsDaySecs; double hourDouble = (solDouble - ((long) solDouble)) * 24; double minuteDouble = (hourDouble - ((long) hourDouble)) * 60; double secondDouble = (minuteDouble - ((long) minuteDouble)) * 60; int sol = (int) (solDouble) + 1; int hour = (int) (hourDouble); int minute = (int) (minuteDouble); ... |
long | megaCyclesToMilliseconds(long megaCycles) mega Cycles To Milliseconds return (long) (1000 * megaCycles / MCYCLES_PER_SECOND); |
long | microsToMillis(long micros) Convert microseconds to milliseconds, ensuring that any microsecond value greater than zero converts to at least one millisecond to avoid a zero millisecond result since Object.wait(0) waits forever. return (micros + 999) / 1000;
|
long | microsToMillis(long sec, long usec) micros To Millis return sec * 1000 + usec / 1000;
|
long | milliDate(String date) Convert a YYYYMMDDHHMMSSTTT date to milliseconds Calendar cal = new GregorianCalendar(); try { cal.set(Integer.parseInt(date.substring(0, 4)), Integer.parseInt(date.substring(4, 6)), Integer.parseInt(date.substring(6, 8)), Integer.parseInt(date.substring(8, 10)), Integer.parseInt(date.substring(10, 12)), Integer.parseInt(date.substring(12, 14))); long milli = cal.getTimeInMillis() + Long.parseLong(date.substring(14)); return milli; } catch (Exception e) { ... |
long | millisBetween(Date firstDate, Date lastDate) Retorna o número de milissegundos entre dias dadas long t1 = firstDate.getTime(); long t2 = lastDate.getTime(); long dif = t1 - t2; if (dif < 0) { dif = dif * (-1); return dif; |
int | millisecond(final Date date) millisecond return fromDateToCalendar(date).get(MILLISECOND);
|
int | millisecondOf(Date date) Extracts the millisecond of the given Date. return toCalendar(date).get(Calendar.MILLISECOND);
|
Date | milliseconds(int offset) milliseconds Calendar c = Calendar.getInstance();
c.set(Calendar.MILLISECOND, c.get(Calendar.MILLISECOND) + offset);
return c.getTime();
|
long | millisecondsBetween(Date start, Date finish) Returns the number of milliseconds between the given Dates. Calendar calendar1 = new GregorianCalendar(); calendar1.setTime(start); Calendar calendar2 = new GregorianCalendar(); calendar2.setTime(finish); return calendar2.getTimeInMillis() - calendar1.getTimeInMillis(); |