Thursday 15 March 2018

Java 8 Year Class Introduction | Java 8 Date and Time | Java Date and Time


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


Click the below Image to Enlarge:

Java 8 Year Class Introduction | Java 8 Date and Time | Java Date and Time
YearDemo1.java

import java.time.Year;

public class YearDemo1
{

    public static void main(String[] args)
    {
        /*
         * Returns:
         *
         * the current year using the system clock and default
         * time-zone, not null
         */

        Year year = Year.now();
        System.out.println(year);
    }

}

Output

2018

YearDemo2.java

import java.time.Year;

public class YearDemo2
{

    public static void main(String[] args)
    {
        /*
         * The minimum supported year
         */

        int minYear = Year.MIN_VALUE;
        System.out.println("Minimum supported year = "+minYear);
       
        /*
         * The maximum supported year
         */

        int maxYear = Year.MAX_VALUE;
        System.out.println("Maximum supported year =  "+maxYear);
    }

}

Output

Minimum supported year = -999999999
Maximum supported year =  999999999

Refer: 
https://docs.oracle.com/javase/8/docs/api/index.html?java/time/Year.html

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

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

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