@@ -0,0 +1,1986 @@
+package com.levelup.java.date.query;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0A%0Aimport java.time.DayOfWeek;%0Aimport java.time.LocalDate;%0Aimport java.time.Month;%0Aimport java.time.temporal.ChronoField;%0Aimport java.time.temporal.TemporalAccessor;%0Aimport java.time.temporal.TemporalQuery;%0Aimport java.util.List;%0Aimport java.util.stream.Collectors;%0A%0Aimport org.junit.Test;%0A%0Aimport com.google.common.collect.Lists;%0A%0A/**%0A * This java example will demonstrate using Java 8 %0A * TemporalQuery.  %0A * %0A * @author Justin Musgrove%0A * @see %3Ca href='http://www.leveluplunch.com/java/examples/workday-temporal-query-java8/'%3EWork day query%3C/a%3E%0A */%0Apublic class WorkDayQuery implements TemporalQuery%3CBoolean%3E%7B%0A%0A%09/* %0A%09 * %0A%09 * (non-Javadoc)%0A%09 * @see java.time.temporal.TemporalQuery#queryFrom(java.time.temporal.TemporalAccessor)%0A%09 */%0A%09@Override%0A%09public Boolean queryFrom(TemporalAccessor date) %7B%0A%09%09%0A%09%09int dayOfWeekNumber = date.get(ChronoField.DAY_OF_WEEK);%0A%09%09DayOfWeek dayOfWeek = DayOfWeek.of(dayOfWeekNumber);%0A%09%09%0A%09%09if (dayOfWeek == DayOfWeek.SATURDAY %7C%7C dayOfWeek == DayOfWeek.SUNDAY) %7B%0A%09%09%09return Boolean.FALSE; %0A%09%09%7D else %7B%0A%09%09%09return Boolean.TRUE; %0A%09%09%7D%0A%09%7D%0A%0A%09%0A%09@Test%0A%09public void work_day_query () %7B%0A%09%09%0A%09%09LocalDate date = LocalDate.of(2014, Month.FEBRUARY, 02); // Sunday%0A%09%09%0A%09%09Boolean workDay = date.query(new WorkDayQuery());%0A%09%09%0A%09%09assertFalse(workDay);%0A%09%7D%0A%09%0A%09@Test%0A%09public void work_day_query_lambda () %7B%0A%09%09%0A%09%09List%3CLocalDate%3E randomDays = Lists.newArrayList(%0A%09%09%09%09LocalDate.of(2014, Month.FEBRUARY, 16), // Sunday%0A%09%09%09%09LocalDate.of(2014, Month.APRIL, 19), // Saturday%0A%09%09%09%09LocalDate.of(2014, Month.MAY, 30), // Friday%0A%09%09%09%09LocalDate.of(2014, Month.DECEMBER, 12), // Friday%0A%09%09%09%09LocalDate.of(2014, Month.DECEMBER, 17) // Wednesday%0A%09%09%09%09);%0A%09%09%0A%09%09// filter work days from random days %0A%09%09List%3CLocalDate%3E workDays = randomDays%0A%09%09%09%09.stream()%0A%09%09%09%09.filter(p -%3E p.query(new WorkDayQuery()))%0A%09%09%09%09.collect(Collectors.toList());%0A%09%09%0A%09%09assertEquals(3, workDays.size());%0A%09%7D%0A%09%0A%7D%0A

add workday query java 8 temporal query