@@ -0,0 +1,1880 @@
+package com.levelup.java.date.query;%0A%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.time.DayOfWeek;%0Aimport java.time.LocalDate;%0Aimport java.time.Month;%0Aimport java.time.temporal.TemporalAccessor;%0Aimport java.time.temporal.TemporalAdjusters;%0Aimport java.time.temporal.TemporalQuery;%0A%0Aimport org.junit.Test;%0A%0A/**%0A * This java example will demonstrate determining if%0A * the date is within daylight saving while using TemporalQuery.%0A * %0A * @author Justin Musgrove%0A * @see %3Ca href='http://www.leveluplunch.com/java/examples/daylight-saving-query-java8/'%3EDaylight saving query%3C/a%3E%0A */%0Apublic class DaylightSavingQuery implements TemporalQuery%3CBoolean%3E %7B%0A%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 temporal) %7B%0A%09%0A%09%09LocalDate date = LocalDate.from(temporal);%0A%09%09%0A%09%09LocalDate secondSundayInMarch = LocalDate%0A%09%09%09.from(date)%0A%09%09%09.withMonth(Month.MARCH.getValue())%0A%09%09%09.with(TemporalAdjusters.firstInMonth(DayOfWeek.SUNDAY))%0A%09%09%09.with(TemporalAdjusters.next(DayOfWeek.SUNDAY));%0A%09%09%0A%09%09LocalDate firstSundayInNovember = LocalDate%0A%09%09%09.from(date)%0A%09%09%09.withMonth(Month.NOVEMBER.getValue())%0A%09%09%09.with(TemporalAdjusters.firstDayOfMonth())%0A%09%09%09.with(TemporalAdjusters.next(DayOfWeek.SUNDAY));%0A%0A%09%09if (date.isAfter(secondSundayInMarch) %7C%7C%0A%09%09%09%09date.isBefore(firstSundayInNovember)) %7B%0A%09%09%09return true;%0A%09%09%7D else %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%7D%0A%09%0A%09@Test%0A%09public void during_daylight_savings ()  %7B%0A%09%09%0A%09%09LocalDate date = LocalDate.of(2014, Month.JULY, 02); %0A%0A%09%09Boolean daylightSavings = date.query(new DaylightSavingQuery());%0A%0A%09%09assertTrue(daylightSavings);%0A%09%7D%0A%09%0A%09@Test%0A%09public void not_during_daylight_savings ()  %7B%0A%09%09%0A%09%09LocalDate date = LocalDate.of(2014, Month.DECEMBER, 02); %0A%0A%09%09Boolean daylightSavings = date.query(new DaylightSavingQuery());%0A%0A%09%09assertTrue(daylightSavings);%0A%09%7D%0A%09%0A%09%0A%0A%7D%0A

add daylight savings query java 8 temporal query