Tuesday 20 February 2018

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


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

Click the below Image to Enlarge

Java 8 ZondedDateTime Class Introduction | Java 8 Date and Time | Java Date and Time
ZoneDateTimeDemo.java

import java.time.ZonedDateTime;

public class ZoneDateTimeDemo
{

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

        ZonedDateTime zonedDateTime = ZonedDateTime.now();
        System.out.println(zonedDateTime);
       
        System.out.println("Year  = "+zonedDateTime.getYear());
        System.out.println("Month = "+zonedDateTime.getMonth());
        System.out.println("Month Value = "+zonedDateTime.getMonthValue());
        System.out.println("getDayOfMonth = "+zonedDateTime.getDayOfMonth());
        System.out.println("Hour = "+zonedDateTime.getHour());
        System.out.println("Min = "+zonedDateTime.getMinute());
        System.out.println("Second = "+zonedDateTime.getSecond());
        System.out.println("Nano Second = "+zonedDateTime.getNano());
        System.out.println("Offset = "+zonedDateTime.getOffset());
        System.out.println("DayOfYear = "+zonedDateTime.getDayOfYear());
        System.out.println("DayOfWeek = "+zonedDateTime.getDayOfWeek());
       
    }

}

Output

2018-02-05T09:58:45.137+05:30[Asia/Calcutta]
Year  = 2018
Month = FEBRUARY
Month Value = 2
getDayOfMonth = 5
Hour = 9
Min = 58
Second = 45
Nano Second = 137000000
Offset = +05:30
DayOfYear = 36
DayOfWeek = MONDAY

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

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/ZoneDateTimeDemo_Intro.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ZoneDateTimeDemo_Intro

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/6f1f0d2759f060503c7b9e4a4259ae3ddbfe139e/BasicJava/ZoneDateTimeDemo_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
  • No comments:

    Post a Comment