Monday 26 March 2018

How to use from method of YearMonth Class | Java 8 Date and Time


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

YearMonthDemo.java

import java.time.LocalDate;
import java.time.YearMonth;

public class YearMonthDemo
{

    public static void main(String[] args)
    {

        LocalDate localDate = LocalDate.now();
        System.out.println("localDate = "+localDate);

        /*
         * Parameters:
         *
         * temporal - the temporal object to convert, not null
         *
         * Returns:
         *
         * the year-month, not null
         */

        YearMonth yearMonth = YearMonth.from(localDate);
        System.out.println("yearMonth = "+yearMonth);

    }

}

Output

localDate = 2018-03-03
yearMonth = 2018-03

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

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

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