Wednesday 25 July 2018

How to use isSet(int field) method of Java.util.calendar class


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

CalendarDemo.java

import java.util.Calendar;

public class CalendarDemo
{
    public static void main(String[] args)
    {
        Calendar cal = Calendar.getInstance();

        /*
         * Parameters:
         *
         * field - the calendar field to test
         *
         * Returns:
         *
         * true if the given calendar field has a value set; false
         * otherwise.
         */

       
        boolean result = cal.isSet(Calendar.DAY_OF_MONTH);
        System.out.println("Day of month is set = " + result);

        // clear day of month
        cal.clear(Calendar.DAY_OF_MONTH);

       
        result = cal.isSet(Calendar.DAY_OF_MONTH);
        System.out.println("Day of month is set = " + result);
    }
}

Output

Day of month is set = true
Day of month is set = false

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

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

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