Java Utililty Methods ZonedDateTime Calculate

List of utility methods to do ZonedDateTime Calculate

Description

The list of methods to do ZonedDateTime Calculate are organized into topic(s).

Method

ZonedDateTimecurrentZonedDateTime()
current Zoned Date Time
Calendar now = Calendar.getInstance();
ZonedDateTime zdt = ZonedDateTime.ofInstant(now.toInstant(), ZoneId.systemDefault());
return zdt;
longdifference(ZonedDateTime t1, ZonedDateTime t2)
difference
return t2.toInstant().toEpochMilli() - t1.toInstant().toEpochMilli();
longdiffMs(ZonedDateTime date1, ZonedDateTime date2)
Finds the difference (in ms) between two LocalDateTime.
return Duration.between(date1, date2).getSeconds() * 1000;
LongelapsedTime(ZonedDateTime zonedDateTime)
elapsed Time
return difference(zonedDateTime, ZonedDateTime.now());
booleanequals(ZonedDateTime ZDT1, ZonedDateTime ZDT2)
equals
return ZDT1 == null ? ZDT2 == null : ZDT2 == null ? false : ZDT1.equals(ZDT2);
Setfilter(final Set list, final ZonedDateTime base, final long minute)
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();
...
intfindIdx(int startidx, int endidx, ZonedDateTime endDate, List holidays)
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)) {
...
longgetDuration(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();
StringgetShortStringDate(ZonedDateTime time)
get Short String Date
return time.format(DateTimeFormatter.ISO_LOCAL_DATE);
ZonedDateTimegetStartOfDay(ZoneId zoneId, ZonedDateTime time)
get Start Of Day
return time.withZoneSameInstant(zoneId).truncatedTo(ChronoUnit.DAYS);