Friday 13 July 2018

How to use getFirstDayOfWeek() method of Java.util.calendar class


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

CalendarDemo.java

import java.util.Calendar;

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

        /*
         * Returns:the first day of the week.
         */

        int firstDayOfTheWeek = cal.getFirstDayOfWeek();

        System.out.println("firstDayOfTheWeek = " + firstDayOfTheWeek);
       
        switch (firstDayOfTheWeek) {
        case (1):
           System.out.println("Sunday");
           break;
        case (2):
           System.out.println("Monday");
           break;
        case 3:
           System.out.println("Tuesday");
           break;
        case 4:
           System.out.println("Wednesday");
           break;
        case 5:
           System.out.println("Thrusday");
           break;
        case 6:
           System.out.println("Friday");
           break;
        case 7:
           System.out.println("Saturday");
           break;
     }
    }
}

Output

firstDayOfTheWeek = 1
Sunday

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

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

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