Created
January 31, 2017 13:51
-
-
Save volost/21de10a8e6f4dfcdd985dbcda9cc20b5 to your computer and use it in GitHub Desktop.
Вычисление разницы между двумя датами:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) throws Exception | |
{ | |
Date currentTime = new Date(); //получаем текущую дату и время | |
Thread.sleep(3000); //ждём 3 секунды – 3000 миллисекунд | |
Date newTime = new Date(); //получаем новое текущее время | |
long msDelay = newTime.getTime() - currentTime.getTime(); //вычисляем разницу | |
System.out.println("Time distance is: " + msDelay + " in ms"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment