Java ZonedDateTime Calculate filter(final Set list, final ZonedDateTime base, final long minute)

Here you can find the source of filter(final Set list, final ZonedDateTime base, final long minute)

Description

filter

License

Open Source License

Declaration

public static Set<ZonedDateTime> filter(final Set<ZonedDateTime> list, final ZonedDateTime base,
        final long minute) 

Method Source Code


//package com.java2s;
import java.time.Duration;
import java.time.ZonedDateTime;
import java.util.Set;
import java.util.stream.Collectors;

public class Main {

    public static Set<ZonedDateTime> filter(final Set<ZonedDateTime> list, final ZonedDateTime base,
            final long minute) {
        if (list == null || base == null) {
            throw new IllegalArgumentException("args must not be null");
        }//from w w w.  j  ava2 s  .  c  o m

        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();
            return (diff == 60);
        }).collect(Collectors.toSet());

        return result;
    }
}

Related

  1. currentZonedDateTime()
  2. difference(ZonedDateTime t1, ZonedDateTime t2)
  3. diffMs(ZonedDateTime date1, ZonedDateTime date2)
  4. elapsedTime(ZonedDateTime zonedDateTime)
  5. equals(ZonedDateTime ZDT1, ZonedDateTime ZDT2)
  6. findIdx(int startidx, int endidx, ZonedDateTime endDate, List holidays)
  7. getDuration(ZonedDateTime input, TemporalField roundTo, int roundIncrement)
  8. getShortStringDate(ZonedDateTime time)
  9. getStartOfDay(ZoneId zoneId, ZonedDateTime time)