Example usage for java.time LocalDate query

List of usage examples for java.time LocalDate query

Introduction

In this page you can find the example usage for java.time LocalDate query.

Prototype

@SuppressWarnings("unchecked")
@Override
public <R> R query(TemporalQuery<R> query) 

Source Link

Document

Queries this date using the specified query.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);
    LocalDate b = a.query(TemporalQueries.localDate());
    System.out.println(b);//w  ww .ja v  a 2  s. c  o m
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate ld1 = LocalDate.of(2013, 12, 1);
    Boolean is = ld1.query(Main::queryFrom);
    System.out.println(is);// w ww.j av a  2s  .  co m
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate ld1 = LocalDate.of(2013, 12, 1);
    Boolean is = ld1.query(new Monday1Query());
    System.out.println(is);/* w  w  w .  j  a  v a  2  s . c  o m*/

}

From source file:Main.java

public static void main(String[] argv) {
    LocalDate date = LocalDate.parse("2013-01-12");
    TemporalQuery<Quarter> quarterOfYearQuery = new QuarterOfYearQuery();

    System.out.println(date.query(quarterOfYearQuery));
}

From source file:Main.java

public static void main(String[] argv) {
    LocalDate date = LocalDate.parse("2013-01-12");
    TemporalQuery<LocalDate> quarterOfYearQuery = new NextMartinLutherKingDayQuery();

    System.out.println(date.query(quarterOfYearQuery));
}

From source file:Main.java

public static void main(String[] args) {
    Month month = Month.valueOf("MARCH");

    int day = 10;
    LocalDate date = LocalDate.of(Year.now().getValue(), month, day);

    // Invoking the query without using a lambda expression.
    Boolean isFamilyVacation = date.query(new FamilyVacations());

    // Invoking the query using a lambda expression.
    Boolean isFamilyBirthday = date.query(FamilyBirthdays::isFamilyBirthday);

    if (isFamilyVacation.booleanValue() || isFamilyBirthday.booleanValue())
        System.out.printf("%s is an important date!%n", date);
    else//w w  w  . j ava2s.co m
        System.out.printf("%s is not an important date.%n", date);
}

From source file:Superstitious.java

public static void main(String[] args) {
    Month month = null;//from  ww  w.  java 2s .  co  m
    LocalDate date = null;

    if (args.length < 2) {
        System.out.printf("Usage: Superstitious <month> <day>%n");
        throw new IllegalArgumentException();
    }

    try {
        month = Month.valueOf(args[0].toUpperCase());
    } catch (IllegalArgumentException exc) {
        System.out.printf("%s is not a valid month.%n", args[0]);
        throw exc; // Rethrow the exception.
    }

    int day = Integer.parseInt(args[1]);

    try {
        date = Year.now().atMonth(month).atDay(day);
    } catch (DateTimeException exc) {
        System.out.printf("%s %s is not a valid date.%n", month, day);
        throw exc; // Rethrow the exception.
    }

    System.out.println(date.query(new FridayThirteenQuery()));
}