Tuesday, 6 February 2018

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


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

Click the below Image to Enlarge

Java 8 OffsetDateTime Class Introduction | Java 8 Date and Time | Java Date and Time
OffsetDateTimeDemo.java

import java.time.OffsetDateTime;

public class OffsetDateTimeDemo
{

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

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

}

Output

2018-01-25T10:04:20.738+05:30
Year  = 2018
Month = JANUARY
Month Value = 1
getDayOfMonth = 25
Hour = 10
Min = 4
Second = 20
Nano Second = 738000000
Offset = +05:30
DayOfYear = 25
DayOfWeek = THURSDAY

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

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

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/1e56a5b0ee03d5726eaa59561253516c29bd898c/BasicJava/OffsetDateTimeDemo_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