You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Util.getNumberOfSecondsFromNow is calculating incorrectly the difference between current and param dates. After testing this locally these were the results:
@Test
public void calcTimeDiff() {
Date time = DateUtils.setYears(new Date(), 2023);
time = DateUtils.setMonths(time, 3);
time = DateUtils.setDays(time, 20);
System.out.println(time);
int result = Util.getNumberOfSecondFromNow(time);
System.out.println("Difference calculated using Util.getNumberOfSecondFromNow = " + result);
System.out.println("Difference using Duration class = " + Duration.between(new Date().toInstant(), time.toInstant()).getSeconds());
}
Result:
Thu Apr 20 14:48:34 BOT 2023
Difference calculated using Util.getNumberOfSecondFromNow = 1471228
Difference using Duration class = 31535999
@yuriyz Do you agree that we could use java.time.Duration instead?
The text was updated successfully, but these errors were encountered:
Util.getNumberOfSecondsFromNow
is calculating incorrectly the difference between current and param dates. After testing this locally these were the results:Result:
@yuriyz Do you agree that we could use
java.time.Duration
instead?The text was updated successfully, but these errors were encountered: