Thursday, 15 February 2018

How to convert temporal object to OffSet Time using from method of OffsetTime Class


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

OffsetTimeDemo.java

import java.time.OffsetTime;
import java.time.ZonedDateTime;

public class OffsetTimeDemo
{

    public static void main(String[] args)
    {
       
        ZonedDateTime zonedDateTime = ZonedDateTime.now();
        System.out.println("zonedDateTime        = " + zonedDateTime);
       
        /*
         * Parameters:
         *
         * temporal - the temporal object to convert, not null
         *
         * Returns:
         *
         * the offset time, not null
         */

        OffsetTime offsetTime = OffsetTime.from(zonedDateTime);
        System.out.println("offsetTime           = " + offsetTime);
    }

}

Output

zonedDateTime        = 2018-02-02T09:44:31.196+05:30[Asia/Calcutta]
offsetTime           = 09:44:31.196+05:30

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

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

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