Monday 5 March 2018

How to use of method of ZoneId Class | Java 8 Date and Time


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

ZoneIdDemo.java

import java.time.LocalDateTime;
import java.time.ZoneId;

public class ZoneIdDemo
{

    public static void main(String[] args)
    {
        /*
         * Parameters:
         *
         * zoneId - the time-zone ID, not null
         *
         * Returns:
         *
         * the zone ID, not null
         */

        ZoneId zoneId1 = ZoneId.of("Asia/Kolkata");
        System.out.println(zoneId1);
        LocalDateTime localDateTime1 = LocalDateTime.now(zoneId1);
        System.out.println(localDateTime1);
       
        System.out.println();
       
        ZoneId zoneId2 = ZoneId.of("Australia/Sydney");
        System.out.println(zoneId2);
        LocalDateTime localDateTime2 = LocalDateTime.now(zoneId2);
        System.out.println(localDateTime2);
    }

}

Output

Asia/Kolkata
2018-02-14T09:57:07.098

Australia/Sydney
2018-02-14T15:27:49.142

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

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4bf907c20b634049430aea37cca3f8775ef090f9/BasicJava/ZoneIdDemo_of_method/?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