Queries this month-day using the specified query.
A custom TemporalQuery example.
package com.logicbig.example.monthday;
import java.time.Month;
import java.time.MonthDay;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalQuery;
public class QueryExample2 {
public static void main(String... args) {
MonthDay m = MonthDay.now();
System.out.println(m);
Boolean b = m.query(MidYearQuery);
System.out.println(b);
MonthDay m2 = MonthDay.of(6, 20);
System.out.println(m2);
Boolean b2 = m2.query(MidYearQuery);
System.out.println(b2);
}
private static final TemporalQuery<Boolean> MidYearQuery = temporal -> {
if (temporal.isSupported(ChronoField.MONTH_OF_YEAR)) {
Month m = Month.from(temporal);
return m == Month.JUNE;
}
return false;
};
}
Output
--05-01
false
--06-20
true