Check out example codes for "teimpo en segundos java". It will help you in understanding the concepts better.

Code Example 1

long inicio = System.currentTimeMillis();
Thread.sleep(2000);
long fin = System.currentTimeMillis();
double tiempo = (double) ((fin - inicio)/1000);

Learn ReactJs, React Native from akashmittal.com