Example usage for java.lang System currentTimeMillis

List of usage examples for java.lang System currentTimeMillis

Introduction

In this page you can find the example usage for java.lang System currentTimeMillis.

Prototype

@HotSpotIntrinsicCandidate
public static native long currentTimeMillis();

Source Link

Document

Returns the current time in milliseconds.

Usage

From source file:Main.java

public static void main(String[] args) {
    long lnSystemTime = System.currentTimeMillis();
    System.out.println("Milliseconds since midnight, January 1, 1970 UTC : " + lnSystemTime);
}

From source file:MainClass.java

public static void main(String[] a) {
    long start = System.currentTimeMillis();

    // block of code to time

    long end = System.currentTimeMillis();
    System.out.println("It took " + (end - start) + " milliseconds");
}

From source file:MainClass.java

public static void main(String[] args) {

    new java.sql.Timestamp(System.currentTimeMillis());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);/*from w ww  .  j  ava2s.  co  m*/

    long elapsedTimeMillis = System.currentTimeMillis() - start;
    System.out.println(elapsedTimeMillis);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);/*from ww  w.java  2  s  .c  o m*/

    // 
    long elapsedTimeMillis = System.currentTimeMillis() - start;
    System.out.println(elapsedTimeMillis);
}

From source file:TimeArray.java

public static void main(String args[]) {
    long startTime = System.currentTimeMillis();
    for (int i = 0, n = Integer.MAX_VALUE; i < n; i++) {
        ;/*from w  ww  .  j  av  a2 s .  co m*/
    }
    long midTime = System.currentTimeMillis();
    for (int i = Integer.MAX_VALUE - 1; i >= 0;) {
        ;
    }
    long endTime = System.currentTimeMillis();
    System.out.println("Increasing: " + (midTime - startTime));
    System.out.println("Decreasing: " + (endTime - midTime));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);/*from w  w w. ja v  a2  s. c  om*/

    // Get elapsed time in milliseconds
    long elapsedTimeMillis = System.currentTimeMillis() - start;

    float elapsedTimeDay = elapsedTimeMillis / (24 * 60 * 60 * 1000F);
    System.out.println(elapsedTimeDay);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);/*from  w  ww.j  av  a  2  s . co m*/

    // Get elapsed time in milliseconds
    long elapsedTimeMillis = System.currentTimeMillis() - start;
    // Get elapsed time in hours
    float elapsedTimeHour = elapsedTimeMillis / (60 * 60 * 1000F);
    System.out.println(elapsedTimeHour);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);/*from   w  w  w  .  j a  va 2s.c om*/

    // Get elapsed time in milliseconds
    long elapsedTimeMillis = System.currentTimeMillis() - start;

    float elapsedTimeSec = elapsedTimeMillis / 1000F;
    System.out.println(elapsedTimeSec);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);//from  w  w w .ja  v  a 2 s .  c  o m

    // Get elapsed time in milliseconds
    long elapsedTimeMillis = System.currentTimeMillis() - start;
    // 
    float elapsedTimeSec = elapsedTimeMillis / 1000F;
    System.out.println(elapsedTimeSec);
}