Sunday 10 June 2018

How to use isSupported(TemporalField field) method of DayOfWeek Enum


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

DayOfWeekDemo.java

import java.time.DayOfWeek;
import java.time.temporal.ChronoField;

public class DayOfWeekDemo
{
    public static void main(String[] args)
    {
        DayOfWeek dayOfWeek = DayOfWeek.MONDAY;
       
        /*
         * Parameters:
         *
         * field - the field to check, null returns false
         *
         * Returns:
         *
         * true if the field is supported on this day-of-week, false
         * if not
         */

        boolean isSupported= dayOfWeek.isSupported(ChronoField.DAY_OF_YEAR);       
        System.out.println(isSupported);
       
        isSupported= dayOfWeek.isSupported(ChronoField.DAY_OF_WEEK);       
        System.out.println(isSupported);
    }

}

Output

false
true

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

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

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