Tuesday 27 February 2018

How to use millis method of Clock class | Java 8 Date and Time


Click here to watch on Youtube :
https://www.youtube.com/watch?v=o1_-1EA-_mE&list=UUhwKlOVR041tngjerWxVccw

ClockDemo.java

import java.time.Clock;

public class ClockDemo
{

    public static void main(String[] args)
    {
        Clock clock = Clock.systemDefaultZone();
        System.out.println("clock = " + clock);

        /*
         * Returns:
         *
         * the current millisecond instant from this clock, measured
         * from the Java epoch of 1970-01-01T00:00Z (UTC), not null
         */

        long millis = clock.millis();
        System.out.println("Clock millis = " + millis);
    }

}

Output

clock = SystemClock[Asia/Calcutta]
Clock millis = 1518409712509

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

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

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