I am trying to time how long a method takes within my application, the issue is that the timing is always showing 0 seconds. What is wrong with my code below?
long currentTimeInMilis = System.currentTimeMillis() % 1000;
public ClassName() {
public void timeMethod() {
long startOfmethod= currentTimeInMilis;
methodToTime();
long endOfMethod= currentTimeInMilis;
long totalTime = endOfMethod= - startOfmethod;
LOGGER.info("[Method Took: {}", DurationFormatUtils.formatDuration(totalTime, "H:mm:ss", true) + "]\n");
}
}
The issue is that I'm getting this output every time, eventhough I know it is taking more than zero seconds :
Method took: 0:0:0: