Wednesday, 21 March 2018

How to create a YearMonth object using of methods of YearMonth Class


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

YearMonthDemo.java

import java.time.Month;
import java.time.YearMonth;

public class YearMonthDemo
{

    public static void main(String[] args)
    {

        /*
         * Parameters:
         *
         * year - the year to represent, from MIN_YEAR to MAX_YEAR
         *
         * month - the month-of-year to represent, from 1 (January) to
         * 12 (December)
         *
         * Returns:
         *
         * the year-month, not null
         */

        YearMonth YearMonth1 = YearMonth.of(2017, 9);
        System.out.println(YearMonth1);

        /*
         * Parameters:
         *
         * year - the year to represent, from MIN_YEAR to MAX_YEAR
         *
         * month - the month-of-year to represent, not null
         *
         * Returns:
         *
         * the year-month, not null
         */

        YearMonth YearMonth2 = YearMonth.of(2017, Month.JANUARY);
        System.out.println(YearMonth2);
    }

}

Output

2017-09
2017-01

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

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/216f8f4e86e1a06aad30bc4ca526053adcad4b65/BasicJava_2018/YearMonthDemo_of_methods/?at=master

See also:
  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • No comments:

    Post a Comment