teimpo en segundos java

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

Also in Java: