Tuesday 5 June 2018

How to use firstDayOfYear(boolean leapYear) method of Month Enum | Java 8 Date and Time


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

MonthDemo.java

import java.time.Month;

public class MonthDemo
{
    public static void main(String[] args)
    {
        Month month = Month.of(2);
        System.out.println("month = "+month);
       
        /*
         * Parameters:
         *
         * leapYear - true if the length is required for a leap year
         *
         * Returns:
         *
         * the day of year corresponding to the first day of this
         * month, from 1 to 336
         */

        int firstDayOfYear = month.firstDayOfYear(false);      
        System.out.println("firstDayOfYear =  "+firstDayOfYear);
    }

}

Output

month = FEBRUARY
firstDayOfYear =  32

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

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

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