String.format( "[ %,.3f s ]", value);
The following code uses System.nanoTime to get a more accurate time, then runs a loop on a Math.log function. Finally, it takes the time and renders the difference between the start time and the end time in seconds the same way Maven would render it.
public class MavenTime { public static void main(String[] argv){ long startTime = System.nanoTime(); double a = 4; for( int i =0; i < 100000; i++ ){ a = a * Math.log( i ); } long endTime = System.nanoTime(); System.out.println( "SUCCESS " + String.format( "[ %,.3f s ]", (float)(((endTime-startTime) ) /1000 )/1000 / 1000) ); } }
SUCCESS [ 0.004 s ]