Monday 2 July 2018

How to use query method of DayOfWeek Enum | Java 8 Date and Time


Click here to watch on Youtube:
https://www.youtube.com/watch?v=l4Lslyy5UJI&list=UUhwKlOVR041tngjerWxVccw

DayOfWeekDemo.java

import java.time.DayOfWeek;
import java.time.temporal.TemporalQueries;
import java.time.temporal.TemporalQuery;
import java.time.temporal.TemporalUnit;

public class DayOfWeekDemo
{
    public static void main(String[] args)
    {
        DayOfWeek dayOfWeek = DayOfWeek.MONDAY;
        TemporalQuery<TemporalUnit> temporalQuery = TemporalQueries.precision();

        /*
         * Parameters:
         *
         * query - the query to invoke, not null
         *
         * Returns:
         *
         * the query result, null may be returned (defined by the
         * query)
         */


        System.out.println(dayOfWeek.query(temporalQuery));

    }

}

Output

Days

Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/DayOfWeekDemo_query.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/DayOfWeekDemo_query

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/bb275a728500f81507bdd46f6424332d29623c06/BasicJava_2018/DayOfWeekDemo_query/?at=master

See also:
  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • No comments:

    Post a Comment