wadha alketbi wrote:Hi
I need help in this code, it give me a wrong result. The inputs are 2 dates and the result is the number of days between these 2 dates without weekend (Friday and Saturday).
wadha alketbi wrote:Thank you for your response, acutely I solve it now
It would be great if you could show us your solution.
Also: if you're on version 8, there is a whole new set of classes that allow you to deal with dates and times (and their "differences") much more easily than with Calendar, which (IMO) is probably one of the worst legacy classes in the Java pantheon.
wadha alketbi wrote:
Thanks. Have a cow!
A couple of things that might make it a bit more "generic":
1. Create a separate method for calculating the difference between two Dates in days, eg:and now you can get a "whole number" of days difference with:
long days = daysBetween(start, end).longValue();
2. Put these methods in a separate utility class (DateUtils?) so that you can re-use them whenever you want.