I need to implement a labor calendar able to count working days and, of course, natural days. The calendar must be able to handle national holidays and these days must be submitted by the user. So, if I need to calculate the difference between two days the counting must ignore Saturdays, Sundays, and Holidays.
The Java class Calendar, doesn't handle holidays or working days, so I need to make it by myself. I have think two possible ways:
First way:
I could implement a new Day
class which would have a boolean isHoliday
to check if that is a working day or not, then create a new class with all the methods I'd need to handle/count the days.
Pros:
- Easy to handle
- I can override/create methods like toString, toDate, etc...
Cons:
- Heavy (Maybe?)
My doubt about this approach is how to store it. It'd mean to make 365 objects and store them in a List
or Linked List
and that's a lot of data to handle.
Second way:
My second idea is to make it more simple. Create an array of Strings
or Dates where I'd store the holidays.
Example new ArrayList<String> freeDays = ["01/01/2019", "05/01/2019", "06/01/2019"...]
and with work with it using a new CalendarUtils class or something like that.
Pros:
- More readable
- Light
Cons:
- Hard to work with
For me the first option looks better, however, I don't want to waste memory or use bad practices.
Which option looks better? Are there any third option?