Java TimeUnit Usage logWatchStop(long start, String... params)

Here you can find the source of logWatchStop(long start, String... params)

Description

log Watch Stop

License

Apache License

Declaration

public static long logWatchStop(long start, String... params) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    public static long logWatchStop(long start, String... params) {
        long stop = System.nanoTime();

        String methodName = Thread.currentThread().getStackTrace()[2].getMethodName();
        String className = Thread.currentThread().getStackTrace()[2].getClassName();
        Logger logger = Logger.getLogger(className);
        long convert = TimeUnit.MILLISECONDS.convert(stop - start, TimeUnit.NANOSECONDS);
        logger.log(Level.INFO, "Class: " + className + " :: " + Arrays.toString(params) + " :: The method: "
                + methodName + " :: Time spend : " + convert + "ms");

        return convert;
    }/*from   ww  w. j a  va  2  s.com*/
}

Related

  1. isTheSameDayCheckSummerTime(final Date day1, final Date day2, final boolean escapeYear)
  2. isTimedOut(long start, long timeout)
  3. isValidTTL(final Integer ttlDurationInSeconds)
  4. julianDayToMillis(int julianDay)
  5. logDuration(org.slf4j.Logger log, String prefix, long startTimeNanos)
  6. mergeResults(List>> futures)
  7. millisBetweenNanoTimes(long startNanos, long endNanos)
  8. millisecondsToHumanReadable(long duration)
  9. millisElapsedSince(long startNanoTime)