Friday, 16 March 2018

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


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

YearDemo.java

import java.time.LocalDate;
import java.time.Year;

public class YearDemo
{

    public static void main(String[] args)
    {

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

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

        Year year = Year.from(localDate);
        System.out.println(year);

    }

}

Output

2018-02-25
2018

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

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/8e3f14caa10b52912934997a22df069c728f47b4/BasicJava_2018/YearDemo_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