List of utility methods to do TimeUnit Usage
ArrayList | getAllCombinations(ArrayList Given a vector of sizes, every possible combination consisting of one member from each groups of a given size is returned. long start = System.currentTimeMillis(); ArrayList<ArrayList<Integer>> combos = new ArrayList<ArrayList<Integer>>(); getAllCombinations(lengths, 0, new ArrayList<Integer>(lengths.size()), combos); System.out.println(combos.size() + " combinations of length " + combos.get(0).size()); long end = System.currentTimeMillis(); System.out.println("Combination computation time: " + TimeUnit.MILLISECONDS.toMinutes(end - start) + " minutes (" + (end - start) + " milliseconds)"); return combos; ... |
long | getAllDaysCount(final long milliseconds) get All Days Count return milliseconds / DATE;
|
long | getBookingDays(Calendar start, Calendar end) Returns the entire number of business booking days between two given dates long diff = end.getTime().getTime() - start.getTime().getTime(); return TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS) + 1; |
Date | getCurrentDateTime(int offsetMin) get Current Date Time return new Date(System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(offsetMin)); |
long | getCurrentTimeMillis() Gets the current time in milliseconds, converting from the nanoseconds returned by System#nanoTime() with TimeUnit#convert(long,TimeUnit) return TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
long | getCurrentTimestamp() get Current Timestamp return TimeUnit.SECONDS.convert(Calendar.getInstance().getTimeInMillis(), TimeUnit.MILLISECONDS);
|
long | getCurrentTimestampInSeconds() Get current time in seconds. return TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
|
Date | getDate(final int oceanTime) Convert the specified Ocean time to a Java Date . return new Date(TimeUnit.MILLISECONDS.convert(((long) oceanTime) + NO_SECONDS_1970_1980, TimeUnit.SECONDS)); |
Date | getDateBefore(final Date day) get Date Before final Calendar c = Calendar.getInstance(); c.setTime(day); final int day1 = c.get(Calendar.DATE); c.set(Calendar.DATE, day1 - 1); return c.getTime(); |
Date | getDateWithoutTime(final Calendar calendar) get Date Without Time calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
|