All Downloads are FREE. Search and download functionalities are using the official Maven repository.

wf.utils.java.time.execution.ExecutionTimeNano Maven / Gradle / Ivy

There is a newer version: 3.3.4
Show newest version
package wf.utils.java.time.execution;

import wf.utils.java.data.number.NumberUtils;

public class ExecutionTimeNano {

    private long startTime;

    public ExecutionTimeNano() {
        this.startTime = System.nanoTime();
    }

    public long getNano(){
        return System.nanoTime() - startTime;
    }

    public double getMillis(){
        return getNano() / 1000000d;
    }

    public double getSeconds(){
        return getNano() / 1000000000d;
    }

    public String getSecondsFormatted(){
        return NumberUtils.formatNumber(getSeconds(), 1);
    }

    public String getSecondsFormatted(int count){
        return NumberUtils.formatNumber(getSeconds(), count);
    }

    public void update(){
        this.startTime = System.nanoTime();
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    @Override
    public String toString() {
        return "ExecutionTimeNano{" +
                "startTime=" + startTime +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy