Hi im trying to show working ours in the calendar. I can put a label above

hi

im trying to show working ours in the calendar. I can put a label above the calendar of cause, but for readability I want to use a recurrent event placed in the morning or setBusinessHours?? Is that once suppoesed to be used for something like that?

I tried this but it has not visible effect as far as I can tell:
calendar.setBusinessHours(new BusinessHours(LocalTime.of(9, 0), LocalTime.of(16, 0),DayOfWeek.MONDAY),
new BusinessHours(LocalTime.of(9, 0), LocalTime.of(16, 0),DayOfWeek.TUESDAY),
new BusinessHours(LocalTime.of(9, 0), LocalTime.of(16, 0),DayOfWeek.WEDNESDAY),
new BusinessHours(LocalTime.of(9, 0), LocalTime.of(16, 0),DayOfWeek.THURSDAY),
new BusinessHours(LocalTime.of(10, 0), LocalTime.of(14, 0),DayOfWeek.FRIDAY));

I also tried this:

        entry.setTitle("Mandag til torsdag 8-14:30");
        entry.setRecurringStartDate(LocalDate.of(2020, 1,1), Timezone.getSystem());
        entry.setRecurringEndDate(LocalDate.of(2022, 1,1), Timezone.getSystem());
        entry.setStart(LocalDateTime.now().withHour(7).withMinute(0));
        entry.setEnd(LocalDateTime.now().withHour(8).withMinute(0));
        entry.setRecurring(true);
        entry.setRecurringDaysOfWeeks(new HashSet<DayOfWeek>(){{ DayOfWeek.MONDAY.getValue(); DayOfWeek.TUESDAY.getValue();DayOfWeek.WEDNESDAY.getValue();DayOfWeek.THURSDAY.getValue(); }});

and added this to the calendar - but it does not show up in the calendar as far as I can tell (probably the last line is incorrect?).

also tried:
entry.setRecurringDaysOfWeeks(new HashSet( Arrays.asList(DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY )));

Hi Jan,

business hours is the working time during the day, so it sounds like it is the optimal way to go for you. If you want to do it with recurring entries, please use setRecurringStartTime / EndTime instead of setStart/End (since these are for single entries and will override the recurring data in the end).

You can also then set these to be rendered as background events, then they will be displayed colored in the background.

thanks, I have it working now.

what is this: set these to be rendered as background events?

entry.setRenderingMode(Entry.RenderingMode.BACKGROUND)