In my project, I need to find duration of staying outside in office time of an employee from goToVisitTime and returnTime. The main concerning point is goToVisitTime and returnTime both are date (java.util) type [getting from other method, can't change anymore] and styingOutSideTime also must be date (java.util) type. For example:
Date goTOvisitTime = "12:25";
Date returnTime = "14:19";
So, output should be like,
styingOutSideTime = "01:54";
Therefore my method looks like below:
public Date getDiffTime(Date goTOvisitTime, Date returnTime) {
//calculate difference
return styingOutSideTime;
}
I have spent lots of time to determine the solution. I tried to use almost all of Date and Time from Java and Joda Time as well. Additionally, I went through the following links
How to calculate time difference in java?
Java how to calculate time differences
Convert seconds value to hours minutes seconds?
How to get hour/minute difference in java
However, almost all of the solutions are either parameter or return value is a string. additionally, returning either hour or minute only.