Wednesday 21 February 2018

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


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

ZoneDateTimeDemo.java

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

public class ZoneDateTimeDemo
{

    public static void main(String[] args)
    {

        OffsetDateTime offsetDateTime = OffsetDateTime.now();
        System.out.println(offsetDateTime);

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

        ZonedDateTime zonedDateTime = ZonedDateTime.from(offsetDateTime);
        System.out.println(zonedDateTime);
    }

}

Output

2018-02-08T09:26:27.428+05:30
2018-02-08T09:26:27.428+05:30

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

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/914905cc2357de2bddb749208190c8f0bf0f9978/BasicJava/ZoneDateTimeDemo_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