Background: My application will not allow for me to bring in external libraries, though some may be accessible. I am working in Java 7. Disclaimer: This is my first Stack question.
My particular project is an effort to take 2 timestamps with just the local date pulled from them, where the first date is a record creation date and the second is a response date, then determine if the dates lay within my working days. I will later find the difference.
I'm already outside my depth by quite a bit, and so I need assistance 'translating' Java 8 code into Java 7.
I've searched some loosely related answers, but I'm struggling to grasp the fundamentals inherent to the concepts.
The primary code
int allDaysBetween = (int) (ChronoUnit.DAYS.between(fromDay, toDay) + 1);
long allWorkingMinutes = IntStream.range(0, allDaysBetween)
.filter(i -> isWorkingDay(from.plusDays(i)))
.count() * WORKING_MINUTES_PER_DAY ;
The supporting code
private boolean isWorkingDay(final LocalDateTime time) {
return time.getDayOfWeek().getValue() < DayOfWeek.SATURDAY.getValue();
}
I'm simply in need of a functional equivalent. From my understanding, plusDays would add to my create date the time where my office is closed, so when I get the diff from my response date, I'll have an int with a smaller value.
The practical application is this:
office closed on 2019-04-05 19:00:00
record created on 2019-04-06 09:35:00
office opens on 2019-04-08 06:00:00
response created on 2019-04-08 07:32:00
Rather than include the weekend time, I want to exclude it so when I find the diff, I end up with the 'correct' number of minutes based on business hours.