Monday, 12 February 2018

How to convert temporal object to OffsetDateTime using from method of OffsetDateTime Class


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

OffsetDateTimeDemo.java

import java.time.OffsetDateTime;
import java.time.ZonedDateTime;

public class OffsetDateTimeDemo
{

    public static void main(String[] args)
    {

        ZonedDateTime zonedDateTime = ZonedDateTime.now();
        System.out.println(zonedDateTime);


        /*
         * Parameters:
         *
         * temporal - the temporal object to convert, not null
         *
         * Returns:
         *
         * the offset date-time, not null
         */

        OffsetDateTime offsetDateTime = OffsetDateTime.from(zonedDateTime);
        System.out.println(offsetDateTime);

    }

}

Output

2018-01-28T08:24:05.350+05:30[Asia/Calcutta]
2018-01-28T08:24:05.350+05:30

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

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/572947048c5892379e75d8e421fa231c20e2d3bc/BasicJava/OffsetDateTimeDemo_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
  • No comments:

    Post a Comment