Example usage for java.time DayOfWeek MONDAY

List of usage examples for java.time DayOfWeek MONDAY

Introduction

In this page you can find the example usage for java.time DayOfWeek MONDAY.

Prototype

DayOfWeek MONDAY

To view the source code for java.time DayOfWeek MONDAY.

Click Source Link

Document

The singleton instance for the day-of-week of Monday.

Usage

From source file:Main.java

private LocalDate getMartinLutherKingDayForDateInYear(int year) {
    return LocalDate.of(year, Month.JANUARY, 1).with(TemporalAdjusters.dayOfWeekInMonth(3, DayOfWeek.MONDAY));
}

From source file:com.thinkenterprise.domain.BoundedContextInitializer.java

private void initRoutes() {

    // Mnchen-Houston LH7902
    ////from  ww  w .j a va2  s  . co  m
    Route route = new Route("LH7902", "MUC", "IAH");
    route.addScheduledDaily();
    route.setDepartureTime(LocalTime.of(9, 30));
    route.setArrivalTime(LocalTime.of(14, 00));

    // Flug am 23.09.2015
    Flight flight = new Flight(120.45, LocalDate.of(2015, 9, 23));
    flight.addEmployee("Fred");
    flight.addEmployee("Sarah");
    route.addFlight(flight);

    // Flug am 24.09.2015
    flight = new Flight(111.45, LocalDate.of(2015, 9, 24));
    route.addFlight(flight);

    routeRepository.save(route);

    // Mnchen-Ibiza LH1602
    //
    route = new Route("LH1602", "MUC", "IBZ");
    route.addScheduledWeekday(DayOfWeek.SATURDAY);
    route.setDepartureTime(LocalTime.of(8, 50));
    route.setArrivalTime(LocalTime.of(11, 15));

    flight = new Flight(120.45, LocalDate.of(2015, 9, 19));
    route.addFlight(flight);

    routeRepository.save(route);

    // Mnchen-Ibiza LH1838
    //
    route = new Route("LH1838", "MUC", "IBZ");
    route.addScheduledWeekday(DayOfWeek.MONDAY);
    route.addScheduledWeekday(DayOfWeek.THURSDAY);
    route.addScheduledWeekday(DayOfWeek.SATURDAY);
    route.setDepartureTime(LocalTime.of(12, 25));
    route.setArrivalTime(LocalTime.of(14, 50));

    flight = new Flight(120.45, LocalDate.of(2015, 9, 19));
    route.setAircraft("D-AIPA");
    route.addFlight(flight);

    routeRepository.save(route);

    // Mnchen-New York LH401
    //
    route = new Route("LH401", "FRA", "NYC");
    route.addScheduledDaily();
    route.setDepartureTime(LocalTime.of(15, 55));
    route.setArrivalTime(LocalTime.of(5, 30));

    flight = new Flight(120.45, LocalDate.of(2015, 9, 30));
    route.setAircraft("D-AIPA");
    route.addFlight(flight);

    routeRepository.save(route);
}

From source file:com.publictransitanalytics.scoregenerator.datalayer.directories.GTFSReadingServiceTypeCalendar.java

private void parseCalendarFile(final Reader calendarReader, final Multimap<LocalDate, String> serviceTypesMap)
        throws IOException {

    final CSVParser calendarParser = new CSVParser(calendarReader, CSVFormat.DEFAULT.withHeader());
    final List<CSVRecord> calendarRecords = calendarParser.getRecords();

    LocalDate earliestDate = null;
    LocalDate latestDate = null;/*w w w  . j  a v a2 s .  c om*/
    for (final CSVRecord record : calendarRecords) {
        final String serviceType = record.get("service_id");

        final LocalDate start = LocalDate.parse(record.get("start_date"), DateTimeFormatter.BASIC_ISO_DATE);
        if (earliestDate == null || start.isBefore(earliestDate)) {
            earliestDate = start;
        }

        final LocalDate end = LocalDate.parse(record.get("end_date"), DateTimeFormatter.BASIC_ISO_DATE);
        if (latestDate == null || end.isAfter(latestDate)) {
            latestDate = end;
        }

        final EnumSet<DayOfWeek> daysOfWeek = EnumSet.noneOf(DayOfWeek.class);
        if (record.get("monday").equals("1")) {
            daysOfWeek.add(DayOfWeek.MONDAY);
        }
        if (record.get("tuesday").equals("1")) {
            daysOfWeek.add(DayOfWeek.TUESDAY);
        }
        if (record.get("wednesday").equals("1")) {
            daysOfWeek.add(DayOfWeek.WEDNESDAY);
        }
        if (record.get("thursday").equals("1")) {
            daysOfWeek.add(DayOfWeek.THURSDAY);
        }
        if (record.get("friday").equals("1")) {
            daysOfWeek.add(DayOfWeek.FRIDAY);
        }
        if (record.get("saturday").equals("1")) {
            daysOfWeek.add(DayOfWeek.SATURDAY);
        }
        if (record.get("sunday").equals("1")) {
            daysOfWeek.add(DayOfWeek.SUNDAY);
        }

        LocalDate targetDate = start;
        while (!targetDate.isAfter(end)) {
            if (daysOfWeek.contains(targetDate.getDayOfWeek())) {
                serviceTypesMap.put(targetDate, serviceType);
            }
            targetDate = targetDate.plusDays(1);
        }
    }
}

From source file:com.nridge.core.base.std.DatUtl.java

/**
 * Calculates the number of business days (excluding weekends)
 * between two dates (inclusive).//from   w  w w.j av a2  s  . com
 * <p>
 * https://stackoverflow.com/questions/4600034/calculate-number-of-weekdays-between-two-dates-in-java
 * </p>
 * @param aStartDate Start date.
 * @param anEndDate End date.
 *
 * @return Number of business days.
 */
@SuppressWarnings("UnnecessaryLocalVariable")
public static long calculateBusinessDays(LocalDate aStartDate, LocalDate anEndDate) {
    DayOfWeek startWeekDay = aStartDate.getDayOfWeek().getValue() < 6 ? aStartDate.getDayOfWeek()
            : DayOfWeek.MONDAY;
    DayOfWeek endWeekDay = anEndDate.getDayOfWeek().getValue() < 6 ? anEndDate.getDayOfWeek()
            : DayOfWeek.FRIDAY;

    long numberOfWeeks = ChronoUnit.DAYS.between(aStartDate, anEndDate) / 7;
    long totalWeekDays = numberOfWeeks * 5 + Math.floorMod(endWeekDay.getValue() - startWeekDay.getValue(), 5);

    return totalWeekDays + 1;
}

From source file:memoryaid.SetReminderController.java

@FXML
private void handleSetReminderBtnAction(ActionEvent event) throws Exception {

    System.out.println("You clicked Add Reminder!");

    String rType = (String) reminderTypeBox.getValue();
    String rName = reminderNameText.getText();
    LocalDate rSDate = startDateId.getValue();
    LocalDate rEDate = endDateId.getValue();
    List<LocalDate> reminderDates = new ArrayList<>();

    String hours = (String) reminderHhBox.getValue();
    String minutes = (String) reminderMmBox.getValue();
    String seconds = (String) reminderSsBox.getValue();
    ObservableList<String> repeat = multiSelectComboBox.getCheckModel().getCheckedItems();

    String imgPath = imagePathText.getText();

    if (rType == null || rName == null || rSDate == null || rEDate == null || hours == null || minutes == null
            || seconds == null || repeat.size() == 0 || imgPath == null) {
        Alert alert = new Alert(AlertType.ERROR);
        alert.setTitle("Error Dialog");
        alert.setHeaderText("Oops, an Error Dialog");
        alert.setContentText("Please fill all the fields");
        alert.showAndWait();//ww  w  .  j  a v a 2  s.  c  o  m
        System.out.println("Please fill all the fields");
    } else if (rSDate.isAfter(rEDate) == true) {
        Alert alert = new Alert(AlertType.ERROR);
        alert.setTitle("Error Dialog");
        alert.setHeaderText("Oops, an Error Dialog");
        alert.setContentText("End date cannot be before the Start date");
        alert.showAndWait();
        System.out.println("End date should be greater than start date");
    } else {
        String rTime = hours + ":" + minutes + ":" + seconds;
        if (rType != null && rName != null && !rName.isEmpty() && rEDate != null && hours != null
                && minutes != null && seconds != null && repeat != null && imgPath != null) {

            String destinationPath = "/Users/madhaviunnam/NetBeansProjects/MemoryAid/src/Reminders";
            File destinationPathObject = new File(destinationPath + "/" + rName + ".png");
            File sourceFilePathObject = new File(imgPath);
            FileUtils.copyFile(sourceFilePathObject, destinationPathObject);

            System.out.println(
                    "You clicked Add Reminder!" + rType + rName + rSDate + rEDate + rTime + repeat + imgPath);
            System.out.println("****Inside if");
            Reminder reminderToSet = new Reminder();
            reminderToSet.setReminderName(rName);
            reminderToSet.setReminderType(rType);
            reminderToSet.setStartDate(rSDate);
            reminderToSet.setEndDate(rEDate);

            //endDateToCheck = rEDate.plusDays(1);

            if (repeat.contains("Every Monday")) {
                reminderToSet.setRepeatMon("true");
                while (rSDate.isBefore(rEDate)) {
                    if (rSDate.getDayOfWeek() == DayOfWeek.MONDAY) {
                        reminderDates.add(rSDate);
                    }
                    rSDate = rSDate.plusDays(1);
                }
                rSDate = startDateId.getValue();
            } else {
                reminderToSet.setRepeatMon("false");
            }
            if (repeat.contains("Every Tuesday")) {
                reminderToSet.setRepeatTue("true");
                while (rSDate.isBefore(rEDate)) {
                    if (rSDate.getDayOfWeek() == DayOfWeek.TUESDAY) {
                        reminderDates.add(rSDate);
                    }
                    rSDate = rSDate.plusDays(1);
                }
                rSDate = startDateId.getValue();
            } else {
                reminderToSet.setRepeatTue("false");
            }
            if (repeat.contains("Every Wednesday")) {
                reminderToSet.setRepeatWed("true");
                while (rSDate.isBefore(rEDate)) {
                    if (rSDate.getDayOfWeek() == DayOfWeek.WEDNESDAY) {
                        reminderDates.add(rSDate);
                    }
                    rSDate = rSDate.plusDays(1);
                }
                rSDate = startDateId.getValue();
            } else {
                reminderToSet.setRepeatWed("false");
            }
            if (repeat.contains("Every Thursday")) {
                reminderToSet.setRepeatThu("true");
                while (rSDate.isBefore(rEDate)) {
                    if (rSDate.getDayOfWeek() == DayOfWeek.THURSDAY) {
                        reminderDates.add(rSDate);
                    }
                    rSDate = rSDate.plusDays(1);
                }
                rSDate = startDateId.getValue();
            } else {
                reminderToSet.setRepeatThu("false");
            }
            if (repeat.contains("Every Friday")) {
                reminderToSet.setRepeatFri("true");
                while (rSDate.isBefore(rEDate)) {
                    if (rSDate.getDayOfWeek() == DayOfWeek.FRIDAY) {
                        reminderDates.add(rSDate);
                    }
                    rSDate = rSDate.plusDays(1);
                }
                rSDate = startDateId.getValue();
            } else {
                reminderToSet.setRepeatFri("false");
            }
            if (repeat.contains("Every Saturday")) {
                reminderToSet.setRepeatSat("true");
                while (rSDate.isBefore(rEDate)) {
                    if (rSDate.getDayOfWeek() == DayOfWeek.SATURDAY) {
                        reminderDates.add(rSDate);
                    }
                    rSDate = rSDate.plusDays(1);
                }
                rSDate = startDateId.getValue();
            } else {
                reminderToSet.setRepeatSat("false");
            }
            if (repeat.contains("Every Sunday")) {
                reminderToSet.setRepeatSun("true");
                while (rSDate.isBefore(rEDate)) {
                    if (rSDate.getDayOfWeek() == DayOfWeek.SUNDAY) {
                        reminderDates.add(rSDate);
                    }
                    rSDate = rSDate.plusDays(1);
                }
            } else {
                reminderToSet.setRepeatSun("false");
            }
            if (repeat.contains("None")) {
                reminderToSet.setRepeatNone("true");
                reminderDates.add(rSDate);
            } else {
                reminderToSet.setRepeatNone("false");
            }

            System.out.println("%%%%Reminder DATes" + reminderDates);
            reminderToSet.setReminderTime(rTime);
            reminderToSet.setReminderStatus("New");

            DbConnection db = new DbConnection();
            Connection conn = db.connect();
            PreparedStatement preparedStmt = null;
            String insertSql = "INSERT into Reminders(ReminderType, ReminderName, StartDate, EndDate, ReminderTime, RepeatM, RepeatT, RepeatW, RepeatTH, RepeatF, RepeatSat, RepeatSun)"
                    + "values(?,?,?,?,?,?,?,?,?,?,?,?)";
            preparedStmt = conn.prepareStatement(insertSql);
            preparedStmt.setString(1, reminderToSet.getReminderType());
            preparedStmt.setString(2, reminderToSet.getReminderName());
            preparedStmt.setString(3, reminderToSet.getStartDate().toString());
            preparedStmt.setString(4, reminderToSet.getEndDate().toString());
            preparedStmt.setString(5, reminderToSet.getReminderTime());
            preparedStmt.setString(6, reminderToSet.getRepeatMon());
            preparedStmt.setString(7, reminderToSet.getRepeatTue());
            preparedStmt.setString(8, reminderToSet.getRepeatWed());
            preparedStmt.setString(9, reminderToSet.getRepeatThu());
            preparedStmt.setString(10, reminderToSet.getRepeatFri());
            preparedStmt.setString(11, reminderToSet.getRepeatSat());
            preparedStmt.setString(12, reminderToSet.getRepeatSun());

            preparedStmt.executeUpdate();
            System.out.println("Reminder Inserted Successfully  ");
            //Get the inserted reminders RId
            String getRIdsql = "Select max(RId) as RId from Reminders";
            ResultSet rSet = conn.createStatement().executeQuery(getRIdsql);
            int newRId = 0;
            while (rSet.next()) {
                newRId = rSet.getInt(1);

            }
            System.out.println("RID ^^^^^^^^" + newRId);
            PreparedStatement preparedStmtRDetails = null;
            for (int i = 0; i < reminderDates.size(); i++) {
                String rDetailsSql = "Insert into ReminderDetails(RId,DetailNum,ReminderDate,ReminderStatus)"
                        + " values(?,?,?,?)";
                preparedStmtRDetails = conn.prepareStatement(rDetailsSql);
                preparedStmtRDetails.setInt(1, newRId);
                preparedStmtRDetails.setInt(2, i);
                preparedStmtRDetails.setString(3, reminderDates.get(i).toString());
                preparedStmtRDetails.setString(4, "New");
                preparedStmtRDetails.executeUpdate();
                System.out.println("ReminderDetails Table Insert Successfull  ");
            }
            Parent setReminder = FXMLLoader.load(getClass().getResource("SetReminder.fxml"));
            Scene set_reminder_refresh_scene = new Scene(setReminder);
            Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
            app_stage.hide();
            app_stage.setScene(set_reminder_refresh_scene);
            app_stage.show();

        } else {
            System.out.println("Inside else");
            //show alert
            Alert alert = new Alert(AlertType.ERROR);
            alert.setTitle("Error Dialog");
            alert.setHeaderText("Oops, an Error Dialog");
            alert.setContentText("Please fill all the fields");
            alert.showAndWait();

        }
    }

}

From source file:mesclasses.view.JourneeController.java

@FXML
public void previousDay() {
    if (currentDate.getValue().getDayOfWeek() == DayOfWeek.MONDAY) {
        setCurrentDateAndSeance(currentDate.getValue().minusDays(2), null);
    } else {//w w w  .j  a v  a 2s  .  c o m
        setCurrentDateAndSeance(currentDate.getValue().minusDays(1), null);
    }
}

From source file:org.silverpeas.core.calendar.icalendar.ICal4JExchangeImportTest.java

@Test
public void severalOfOneHourDurationAndDailyRecurrence() throws ImportException {
    CalendarEvent event1 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T12:32:00Z"), datetime("2016-12-15T13:32:00Z")))
            .withExternalId("EXT-EVENT-UUID-1").withTitle("EVENT-TITLE-1").withPriority(Priority.HIGH)
            .withVisibilityLevel(VisibilityLevel.PRIVATE).withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z")).withRecurrence(Recurrence.every(TimeUnit.DAY))
            .build();/*from w  w  w  .j  a  v  a2s.  c  o m*/
    CalendarEvent event2 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T13:50:00Z"), datetime("2016-12-15T14:50:00Z")))
            .withExternalId("EVENT-UUID-2").withTitle("EVENT-TITLE-2")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(3, TimeUnit.DAY)).build();
    CalendarEvent event3 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T15:27:00Z"), datetime("2016-12-15T16:27:00Z")))
            .withExternalId("EVENT-UUID-3").withTitle("EVENT-TITLE-3")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(4, TimeUnit.DAY).until(datetime("2016-12-31T15:27:00Z"))).build();
    CalendarEvent event4 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T18:45:00Z"), datetime("2016-12-15T20:15:00Z")))
            .withExternalId("EVENT-UUID-4").withTitle("EVENT-TITLE-4")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(2, TimeUnit.DAY).until(10)).build();
    CalendarEvent event5 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T20:00:00Z"), datetime("2016-12-15T20:15:00Z")))
            .withExternalId("EVENT-UUID-5").withTitle("EVENT-TITLE-5")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.DAY).excludeEventOccurrencesStartingAt(date("2016-12-18"),
                    date("2016-12-20"), date("2016-12-25")))
            .build();
    CalendarEvent event6 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T20:30:00Z"), datetime("2016-12-15T20:45:00Z")))
            .withExternalId("EVENT-UUID-6").withTitle("EVENT-TITLE-6")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z")).withRecurrence(Recurrence
                    .every(2, TimeUnit.WEEK).on(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY, DayOfWeek.FRIDAY))
            .build();
    CalendarEvent event7 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T21:00:00Z"), datetime("2016-12-15T21:15:00Z")))
            .withExternalId("EVENT-UUID-7").withTitle("EVENT-TITLE-7")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(
                    Recurrence.every(1, TimeUnit.MONTH).on(DayOfWeekOccurrence.nth(3, DayOfWeek.FRIDAY)))
            .build();
    CalendarEvent event8 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T21:15:00Z"), datetime("2016-12-15T21:30:00Z")))
            .withExternalId("EVENT-UUID-8").withTitle("EVENT-TITLE-8")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.MONTH)).build();
    CalendarEvent event9 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T21:45:00Z"), datetime("2016-12-15T22:00:00Z")))
            .withExternalId("EVENT-UUID-9").withTitle("EVENT-TITLE-9")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.YEAR)).build();

    importAndVerifyResult("ical4j_import_several_with_recurrence.txt",
            asList(event1, event2, event3, event4, event5, event6, event7, event8, event9), defaultAssert);
}

From source file:org.silverpeas.core.calendar.icalendar.ICal4JExchangeImportTest.java

@Test
public void severalOnAllDaysAndDailyRecurrence() throws ImportException {
    CalendarEvent event1 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-15")))
            .withExternalId("EXT-EVENT-UUID-1").withTitle("EVENT-TITLE-1")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z")).withRecurrence(Recurrence.every(TimeUnit.DAY))
            .build();/* ww w  .  ja  va2  s .c  o m*/
    CalendarEvent event2 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-15")))
            .withExternalId("EVENT-UUID-2").withTitle("EVENT-TITLE-2")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(3, TimeUnit.DAY)).build();
    CalendarEvent event3 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-15")))
            .withExternalId("EVENT-UUID-3").withTitle("EVENT-TITLE-3")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(4, TimeUnit.DAY).until(date("2016-12-31"))).build();
    CalendarEvent event4 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-15")))
            .withExternalId("EVENT-UUID-4").withTitle("EVENT-TITLE-4")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(2, TimeUnit.DAY).until(10)).build();
    CalendarEvent event5 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-15")))
            .withExternalId("EVENT-UUID-5").withTitle("EVENT-TITLE-5")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.DAY).excludeEventOccurrencesStartingAt(date("2016-12-18"),
                    date("2016-12-20"), date("2016-12-25")))
            .build();
    CalendarEvent event6 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-15")))
            .withExternalId("EVENT-UUID-6").withTitle("EVENT-TITLE-6")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z")).withRecurrence(Recurrence
                    .every(2, TimeUnit.WEEK).on(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY, DayOfWeek.FRIDAY))
            .build();
    CalendarEvent event7 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-15")))
            .withExternalId("EVENT-UUID-7").withTitle("EVENT-TITLE-7")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(
                    Recurrence.every(1, TimeUnit.MONTH).on(DayOfWeekOccurrence.nth(3, DayOfWeek.FRIDAY)))
            .build();
    CalendarEvent event8 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-15")))
            .withExternalId("EVENT-UUID-8").withTitle("EVENT-TITLE-8")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.MONTH)).build();
    CalendarEvent event9 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-15")))
            .withExternalId("EVENT-UUID-9").withTitle("EVENT-TITLE-9")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.YEAR)).build();

    importAndVerifyResult("ical4j_import_several_with_recurrence_on_all_day.txt",
            asList(event1, event2, event3, event4, event5, event6, event7, event8, event9), defaultAssert);
}

From source file:org.silverpeas.core.calendar.icalendar.ICal4JExporterTest.java

@Test
public void severalOfOneHourDurationAndDailyRecurrence() throws ExportException {
    CalendarEvent event1 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T12:32:00Z"), datetime("2016-12-15T13:32:00Z")))
            .plannedOn(calendar).withId("EVENT-UUID-1").withExternalId("EXT-EVENT-UUID-1")
            .withTitle("EVENT-TITLE-1").withPriority(Priority.HIGH).withVisibilityLevel(PRIVATE)
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z")).withRecurrence(Recurrence.every(TimeUnit.DAY))
            .build();// ww w.j a  v a 2s.co  m
    CalendarEvent event2 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T13:50:00Z"), datetime("2016-12-15T14:50:00Z")))
            .plannedOn(calendar).withId("EVENT-UUID-2").withTitle("EVENT-TITLE-2")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(3, TimeUnit.DAY)).build();
    CalendarEvent event3 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T15:27:00Z"), datetime("2016-12-15T16:27:00Z")))
            .plannedOn(calendar).withId("EVENT-UUID-3").withTitle("EVENT-TITLE-3")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(4, TimeUnit.DAY).until(datetime("2016-12-31T15:27:00Z"))).build();
    CalendarEvent event4 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T18:45:00Z"), datetime("2016-12-15T20:15:00Z")))
            .plannedOn(calendar).withId("EVENT-UUID-4").withTitle("EVENT-TITLE-4")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(2, TimeUnit.DAY).until(10)).build();
    CalendarEvent event5 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T20:00:00Z"), datetime("2016-12-15T20:15:00Z")))
            .plannedOn(calendar).withId("EVENT-UUID-5").withTitle("EVENT-TITLE-5")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.DAY).excludeEventOccurrencesStartingAt(date("2016-12-18"),
                    date("2016-12-20"), date("2016-12-25")))
            .build();
    CalendarEvent event6 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T20:30:00Z"), datetime("2016-12-15T20:45:00Z")))
            .plannedOn(calendar).withId("EVENT-UUID-6").withTitle("EVENT-TITLE-6")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z")).withRecurrence(Recurrence
                    .every(2, TimeUnit.WEEK).on(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY, DayOfWeek.FRIDAY))
            .build();
    CalendarEvent event7 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T21:00:00Z"), datetime("2016-12-15T21:15:00Z")))
            .plannedOn(calendar).withId("EVENT-UUID-7").withTitle("EVENT-TITLE-7")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(
                    Recurrence.every(1, TimeUnit.MONTH).on(DayOfWeekOccurrence.nth(3, DayOfWeek.FRIDAY)))
            .build();
    CalendarEvent event8 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T21:15:00Z"), datetime("2016-12-15T21:30:00Z")))
            .plannedOn(calendar).withId("EVENT-UUID-8").withTitle("EVENT-TITLE-8")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.MONTH)).build();
    CalendarEvent event9 = CalendarEventStubBuilder
            .from(Period.between(datetime("2016-12-15T21:45:00Z"), datetime("2016-12-15T22:00:00Z")))
            .plannedOn(calendar).withId("EVENT-UUID-9").withTitle("EVENT-TITLE-9")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.YEAR)).build();

    exportAndVerifyResult(newExportDescriptor(),
            asList(event1, event2, event3, event4, event5, event6, event7, event8, event9),
            "ical4j_export_several_with_recurrence.txt");
}

From source file:org.silverpeas.core.calendar.icalendar.ICal4JExporterTest.java

@Test
public void severalOnAllDaysAndDailyRecurrence() throws ExportException {
    CalendarEvent event1 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-16")))
            .plannedOn(calendar).withId("EVENT-UUID-1").withExternalId("EXT-EVENT-UUID-1")
            .withTitle("EVENT-TITLE-1").withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z")).withRecurrence(Recurrence.every(TimeUnit.DAY))
            .build();//from  w w  w.ja v  a2s .  c om
    CalendarEvent event2 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-16")))
            .plannedOn(calendar).withId("EVENT-UUID-2").withTitle("EVENT-TITLE-2")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(3, TimeUnit.DAY)).build();
    CalendarEvent event3 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-16")))
            .plannedOn(calendar).withId("EVENT-UUID-3").withTitle("EVENT-TITLE-3")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(4, TimeUnit.DAY).until(date("2016-12-31"))).build();
    CalendarEvent event4 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-16")))
            .plannedOn(calendar).withId("EVENT-UUID-4").withTitle("EVENT-TITLE-4")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(2, TimeUnit.DAY).until(10)).build();
    CalendarEvent event5 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-16")))
            .plannedOn(calendar).withId("EVENT-UUID-5").withTitle("EVENT-TITLE-5")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.DAY).excludeEventOccurrencesStartingAt(date("2016-12-18"),
                    date("2016-12-20"), date("2016-12-25")))
            .build();
    CalendarEvent event6 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-16")))
            .plannedOn(calendar).withId("EVENT-UUID-6").withTitle("EVENT-TITLE-6")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z")).withRecurrence(Recurrence
                    .every(2, TimeUnit.WEEK).on(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY, DayOfWeek.FRIDAY))
            .build();
    CalendarEvent event7 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-16")))
            .plannedOn(calendar).withId("EVENT-UUID-7").withTitle("EVENT-TITLE-7")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(
                    Recurrence.every(1, TimeUnit.MONTH).on(DayOfWeekOccurrence.nth(3, DayOfWeek.FRIDAY)))
            .build();
    CalendarEvent event8 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-16")))
            .plannedOn(calendar).withId("EVENT-UUID-8").withTitle("EVENT-TITLE-8")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.MONTH)).build();
    CalendarEvent event9 = CalendarEventStubBuilder.from(Period.between(date("2016-12-15"), date("2016-12-16")))
            .plannedOn(calendar).withId("EVENT-UUID-9").withTitle("EVENT-TITLE-9")
            .withCreationDate(datetime("2016-12-01T14:30:00Z"))
            .withLastUpdateDate(datetime("2016-12-02T09:00:00Z"))
            .withRecurrence(Recurrence.every(TimeUnit.YEAR)).build();

    exportAndVerifyResult(newExportDescriptor(),
            asList(event1, event2, event3, event4, event5, event6, event7, event8, event9),
            "ical4j_export_several_with_recurrence_on_all_day.txt");
}