Friday, 8 June 2018

How to use query(TemporalQuery query) method of Month Enum | Java 8 Date and Time


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


MonthDemo.java

import java.time.Month;
import java.time.temporal.TemporalQueries;
import java.time.temporal.TemporalUnit;

public class MonthDemo
{
    public static void main(String[] args)
    {
        Month month = Month.of(2);

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

        TemporalUnit temporalUnit = month.query(TemporalQueries.precision());
        System.out.println(temporalUnit);
    }

}

Output

Months

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

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/23d89f367bac9ed4230eafe0abaf49c0a80cc445/BasicJava_2018/MonthDemo_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