List of utility methods to do ZonedDateTime Calculate
ZonedDateTime | currentZonedDateTime() current Zoned Date Time Calendar now = Calendar.getInstance();
ZonedDateTime zdt = ZonedDateTime.ofInstant(now.toInstant(), ZoneId.systemDefault());
return zdt;
|
long | difference(ZonedDateTime t1, ZonedDateTime t2) difference return t2.toInstant().toEpochMilli() - t1.toInstant().toEpochMilli();
|
long | diffMs(ZonedDateTime date1, ZonedDateTime date2) Finds the difference (in ms) between two LocalDateTime. return Duration.between(date1, date2).getSeconds() * 1000;
|
Long | elapsedTime(ZonedDateTime zonedDateTime) elapsed Time return difference(zonedDateTime, ZonedDateTime.now());
|
boolean | equals(ZonedDateTime ZDT1, ZonedDateTime ZDT2) equals return ZDT1 == null ? ZDT2 == null : ZDT2 == null ? false : ZDT1.equals(ZDT2);
|
Set | filter(final Set filter if (list == null || base == null) { throw new IllegalArgumentException("args must not be null"); if (minute < 0) { throw new IllegalArgumentException("minute must be potitive"); final Set<ZonedDateTime> result = list.stream().filter(p -> { final long diff = Duration.between(base, p).toMinutes(); ... |
int | findIdx(int startidx, int endidx, ZonedDateTime endDate, List find Idx if (startidx == endidx) { return startidx; int pivot = (endidx - startidx) / 2; if (holidays.get(pivot).equals(endDate)) { return pivot; if (holidays.get(pivot).isBefore(endDate)) { ... |
long | getDuration(ZonedDateTime input, TemporalField roundTo, int roundIncrement) Returns the time in nanoseconds (long) until the next rounded time. int field = input.get(roundTo); int r = field % roundIncrement; ZonedDateTime ceiling = input.plus(roundIncrement - r, roundTo.getBaseUnit()) .truncatedTo(roundTo.getBaseUnit()); return Duration.between(input, ceiling).getSeconds(); |
String | getShortStringDate(ZonedDateTime time) get Short String Date return time.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
ZonedDateTime | getStartOfDay(ZoneId zoneId, ZonedDateTime time) get Start Of Day return time.withZoneSameInstant(zoneId).truncatedTo(ChronoUnit.DAYS);
|