Example usage for com.liferay.portal.kernel.util CalendarFactoryUtil getCalendar

List of usage examples for com.liferay.portal.kernel.util CalendarFactoryUtil getCalendar

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util CalendarFactoryUtil getCalendar.

Prototype

public static Calendar getCalendar(int year, int month, int date, int hour, int minute, int second,
            int millisecond, TimeZone timeZone) 

Source Link

Usage

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testAddRecurringCalendarBookingUntilStartTime() throws Exception {

    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, _losAngelesTimeZone, serviceContext);

    java.util.Calendar startTimeJCalendar = CalendarFactoryUtil.getCalendar(2017, java.util.Calendar.JANUARY, 1,
            20, 0, 0, 0, _losAngelesTimeZone);

    java.util.Calendar untilJCalendar = (java.util.Calendar) startTimeJCalendar.clone();

    Recurrence recurrence = RecurrenceTestUtil.getDailyRecurrence(_losAngelesTimeZone, untilJCalendar);

    long startTime = startTimeJCalendar.getTimeInMillis();

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRecurringCalendarBooking(_user, calendar,
            startTime, startTime + (Time.HOUR * 10), recurrence, serviceContext);

    long calendarBookingId = calendarBooking.getCalendarBookingId();

    assertCalendarBookingInstancesCount(calendarBookingId, 1);
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testUpdateRecurringCalendarBookingLastInstance() throws Exception {

    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, _losAngelesTimeZone, serviceContext);

    java.util.Calendar startTimeJCalendar = CalendarFactoryUtil.getCalendar(2017, java.util.Calendar.JANUARY, 1,
            20, 0, 0, 0, _losAngelesTimeZone);

    Recurrence recurrence = RecurrenceTestUtil.getDailyRecurrence(3, _losAngelesTimeZone);

    long startTime = startTimeJCalendar.getTimeInMillis();

    long endTime = startTime + (Time.HOUR * 10);

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRecurringCalendarBooking(_user, calendar,
            startTime, endTime, recurrence, serviceContext);

    long calendarBookingId = calendarBooking.getCalendarBookingId();

    assertCalendarBookingInstancesCount(calendarBookingId, 3);

    recurrence = RecurrenceTestUtil.getDailyRecurrence(_losAngelesTimeZone, startTimeJCalendar);

    CalendarBookingLocalServiceUtil.updateCalendarBooking(calendarBooking.getUserId(), calendarBookingId,
            calendar.getCalendarId(), calendarBooking.getTitleMap(), calendarBooking.getDescriptionMap(),
            calendarBooking.getLocation(), startTime, endTime, false,
            RecurrenceSerializer.serialize(recurrence), calendarBooking.getFirstReminder(),
            calendarBooking.getFirstReminderType(), calendarBooking.getSecondReminder(),
            calendarBooking.getSecondReminderType(), serviceContext);

    assertCalendarBookingInstancesCount(calendarBookingId, 1);
}