Saturday, 10 June 2017

Java Tutorial: System class in java [How to get Current time in ms] ~ foundjava


Click here to watch in Youtube :

https://www.youtube.com/watch?v=roTe2_lI26A&list=UUhwKlOVR041tngjerWxVccw

SystemDemo.java

import java.io.IOException;
import java.util.Date;

public class SystemDemo
{

    public static void main(String[] args) throws IOException
    {
        /*
         * Returns the current time in milliseconds.
         */
        long currentTimeInms = System.currentTimeMillis();
        System.out.println("Current Time in milliseconds = " + currentTimeInms);
        
        Date date = new Date(currentTimeInms);      
        System.out.println("Current date and Time = "+date);

    }
}
Output
Current Time in milliseconds = 1488772077364
Current date and Time = Mon Mar 06 09:17:57 IST 2017

Click the below link to download the code:

CLICK HERE

No comments:

Post a Comment