Calendar Toolbox API

Package Overview

The library is organised under the base package com.onixbyte.calendar with the following structure:

PackageDescription
com.onixbyte.calendarRoot calendar object
com.onixbyte.calendar.componentiCalendar components (VEVENT, VTODO, etc.)
com.onixbyte.calendar.component.propertyComponent-level properties
com.onixbyte.calendar.propertyCalendar-level properties
com.onixbyte.calendar.parameteriCalendar property parameters
com.onixbyte.calendar.recurrenceRecurrence rule types
com.onixbyte.calendar.valueValue types
com.onixbyte.calendar.utilFormatting utilities

Calendar

The top-level object representing an iCalendar (RFC 5545) VCALENDAR container.

Calendar calendar = Calendar.builder()
    .withCalendarScale(...)
    .withMethod(...)
    .withProductIdentifier(...)
    .withVersion(...)
    .withOwner(...)
    .withPrimaryCalendar(...)
    .withPublishedTTL(...)
    .withCalendarDescription(...)
    .withCalendarName(...)
    .withCalendarId(...)
    .withCustomProperties(...)
    .withComponents(event, todo, ...)
    .build();

String icsContent = calendar.formatted();

Calendar Properties

All calendar-level properties live in com.onixbyte.calendar.property and implement CalendarProperty.

ClassiCalendar PropertyDescription
CalendarScaleCALSCALECalendar system (e.g., GREGORIAN)
MethodMETHODiCalendar method (e.g., PUBLISH, REQUEST)
ProductIdentifierPRODIDProduct identifier of the calendar
VersionVERSIONiCalendar version (e.g., 2.0)
OwnerX-OWNEROwner of the calendar
PrimaryCalendarX-PRIMARY-CALENDARWhether this is a primary calendar
PublishedTTLX-PUBLISHED-TTLTime-to-live for published calendar
CalendarDescriptionX-CALENDAR-DESCCalendar description
CalendarNameX-CALENDAR-NAMECalendar name
CalendarIdX-CALENDAR-IDCalendar identifier
CustomCalendarPropertyX-*Custom calendar properties

Custom properties are created using a builder:

var customProp = CustomCalendarProperty.builder()
    .withParameters(...)
    .build("X-MY-PROPERTY", "my-value");

Note: Custom property names must start with X-.


Components

Components represent the core entities in an iCalendar object. Each component implements CalendarComponent and is rendered between BEGIN:TYPE and END:TYPE delimiters.

Event (VEVENT)

Represents a scheduled event.

Event event = Event.builder()
    .withDateTimeStamp(dtstamp)        // required
    .withUniqueIdentifier(uid)         // required
    .withDateTimeStart(dtstart)
    .withDateTimeEnd(dtend)            // mutually exclusive with duration
    .withDuration(duration)            // mutually exclusive with dtend
    .withSummary(summary)
    .withDescription(description)
    .withClassification(classification)
    .withDateTimeCreated(dateTimeCreated)
    .withGeographicPosition(geoPos)
    .withLastModified(lastModified)
    .withLocation(location)
    .withOrganiser(organiser)
    .withPriority(priority)
    .withSequenceNumber(seqNumber)
    .withStatus(status)
    .withTimeTransparency(transparency)
    .withUniformResourceLocator(url)
    .withRecurrenceId(recurrenceId)
    .withRecurrenceRule(rrule)
    .withAttachments(attachments)
    .withAttendees(attendees)
    .withCategories(categories)
    .withComments(comments)
    .withContacts(contacts)
    .withExceptionDateTimes(exDates)
    .withRequestStatuses(statuses)
    .withRelated(related)
    .withResources(resources)
    .withRecurrenceDateTimes(rDates)
    .build();

Todo (VTODO)

Represents a to-do item or task.

Todo todo = Todo.builder()
    .withDateTimeStamp(dtstamp)        // required
    .withUniqueIdentifier(uid)         // required
    .withSummary(summary)
    .withDateTimeStart(dtstart)
    .withDateTimeDue(due)              // mutually exclusive with duration
    .withDuration(duration)            // mutually exclusive with due
    .withDateTimeCompleted(completed)
    .withPercentComplete(percent)
    .withClassification(classification)
    .withDateTimeCreated(created)
    .withDescription(description)
    .withGeographicPosition(geoPos)
    .withLastModified(lastModified)
    .withLocation(location)
    .withOrganiser(organiser)
    .withPriority(priority)
    .withSequenceNumber(seq)
    .withStatus(status)
    .withRecurrenceId(recurId)
    .withRecurrenceRule(rrule)
    .withUniformResourceLocator(url)
    .withAttachments(attachments)
    .withAttendees(attendees)
    .withCategories(categories)
    .withComments(comments)
    .withContacts(contacts)
    .withExceptionDateTimes(exDates)
    .withRequestStatuses(statuses)
    .withRelatedToList(related)
    .withResources(resources)
    .withRecurrenceDateTimes(rDates)
    .build();

Journal (VJOURNAL)

Represents a journal entry or diary note.

Journal journal = Journal.builder()
    .withDateTimeStamp(dtstamp)        // required
    .withUniqueIdentifier(uid)         // required
    .withSummary(summary)
    .withClassification(classification)
    .withDateTimeCreated(created)
    .withDateTimeStart(dtstart)
    .withLastModified(lastModified)
    .withOrganiser(organiser)
    .withRecurrenceId(recurId)
    .withSequenceNumber(seq)
    .withStatus(status)
    .withUniformResourceLocator(url)
    .withRecurrenceRule(rrule)
    .withAttachments(attachments)
    .withAttendees(attendees)
    .withCategories(categories)
    .withComments(comments)
    .withContacts(contacts)
    .withDescriptions(descriptions)
    .withExceptionDateTimes(exDates)
    .withRelatedToList(related)
    .withRecurrenceDate(rDates)
    .withRequestStatuses(statuses)
    .build();

FreeBusy (VFREEBUSY)

Represents free/busy time information.

FreeBusy freeBusy = FreeBusy.builder()
    .withDateTimeStamp(dtstamp)        // required
    .withUniqueIdentifier(uid)         // required
    .withContact(contact)
    .withDateTimeStart(dtstart)
    .withDateTimeEnd(dtend)
    .withOrganiser(organiser)
    .withUniformResourceLocator(url)
    .withAttendees(attendees)
    .withComments(comments)
    .withFreeBusyTimes(freeBusyTimes)
    .withRequestStatuses(statuses)
    .build();

TimeZone (VTIMEZONE)

Defines time zone rules including standard and daylight saving time transitions.

TimeZone timezone = TimeZone.builder()
    .withTimeZoneIdentifier(tzId)
    .withLastModified(lastModified)
    .withTimeZoneUrl(tzUrl)
    .withTimeZoneProperties(standardProp, daylightProp)
    .build();

Time zone properties define the actual transition rules:

TimeZoneProperty standard = TimeZoneProperty.builder()
    .withDateTimeStart(dtstart)
    .withTimeZoneOffsetTo(offsetTo)
    .withTimeZoneOffsetFrom(offsetFrom)
    .withRecurrenceRule(rrule)
    .withTimeZoneNames(tzName)
    .buildStandard();                  // or buildDaylight()

TimeZoneProperty daylight = TimeZoneProperty.builder()
    .withDateTimeStart(dtstart)
    .withTimeZoneOffsetTo(offsetTo)
    .withTimeZoneOffsetFrom(offsetFrom)
    .buildDaylight();

Alarm (VALARM)

Defines alarm/reminder notifications. Three alarm types are supported:

// Audio alarm
Alarm audioAlarm = Alarm.builder()
    .withTrigger(trigger)
    .withDuration(duration)
    .withRepeatCount(repeatCount)
    .withAttachments(audioAttachment)
    .buildAudio();

// Display alarm
Alarm displayAlarm = Alarm.builder()
    .withTrigger(trigger)
    .withDescription(description)      // required
    .withDuration(duration)
    .withRepeatCount(repeatCount)
    .buildDisplay();

// Email alarm
Alarm emailAlarm = Alarm.builder()
    .withTrigger(trigger)
    .withDescription(description)      // required
    .withSummary(summary)              // required
    .withAttendees(attendees)          // required
    .withDuration(duration)
    .withRepeatCount(repeatCount)
    .buildEmail();

Component Properties

Component properties live in com.onixbyte.calendar.component.property and implement ComponentProperty.

ClassiCalendar PropertyDescription
ActionACTIONAlarm action type (AUDIO, DISPLAY, EMAIL)
AttachmentATTACHDocument attachment
AttendeeATTENDEEEvent/task attendee
CategoriesCATEGORIESCategories or tags
ClassificationCLASSAccess classification (PUBLIC, PRIVATE, CONFIDENTIAL)
CommentCOMMENTComment
ContactCONTACTContact information
DateTimeCompletedCOMPLETEDCompletion date-time
DateTimeCreatedCREATEDCreation date-time
DateTimeDueDUEDue date-time
DateTimeEndDTENDEnd date-time
DateTimeStampDTSTAMPDate-time stamp
DateTimeStartDTSTARTStart date-time
DescriptionDESCRIPTIONDescription
ExceptionDateTimesEXDATEException date-times
FreeBusyTimeFREEBUSYFree/busy time periods
GeographicPositionGEOGeographic position (lat/long)
LastModifiedLAST-MODIFIEDLast modified date-time
LocationLOCATIONLocation
OrganiserORGANIZEREvent organiser
PercentCompletePERCENT-COMPLETECompletion percentage
PriorityPRIORITYPriority level
RecurrenceDateTimesRDATERecurrence date-times
RecurrenceIdRECURRENCE-IDRecurrence instance identifier
RecurrenceRuleRRULERecurrence rule
RelatedToRELATED-TORelated component reference
RepeatCountREPEATAlarm repeat count
RequestStatusREQUEST-STATUSRequest status
ResourcesRESOURCESResources
SequenceNumberSEQUENCESequence number (revision)
StatusSTATUSComponent status (TENTATIVE, CONFIRMED, CANCELLED, etc.)
SummarySUMMARYTitle or summary
TimeTransparencyTRANSPTime transparency (OPAQUE, TRANSPARENT)
TimeZoneIdentifierTZIDTime zone identifier
TimeZoneNameTZNAMETime zone name
TimeZoneOffsetFromTZOFFSETFROMTime zone offset from UTC
TimeZoneOffsetToTZOFFSETTOTime zone offset to UTC
TimeZoneUrlTZURLTime zone URL
TriggerTRIGGERAlarm trigger
UniformResourceLocatorURLAssociated URL
UniqueIdentifierUIDUnique identifier
CustomComponentPropertyX-*Custom component properties

Parameters

Parameters in com.onixbyte.calendar.parameter provide additional qualifiers on component properties.

ClassiCalendar ParameterDescription
AlarmTriggerRelationshipRELATEDTrigger relationship (START, END)
AlternateTextRepresentationALTREPAlternate text URI
CalendarUserTypeCUTYPECalendar user type (INDIVIDUAL, GROUP, RESOURCE, etc.)
CommonNameCNCommon name
DelegateesDELEGATED-TODelegatees
DelegatorsDELEGATED-FROMDelegators
DirectoryEntryReferenceDIRDirectory entry URI
FormatTypeFMTTYPEFormat type (MIME type)
FreeBusyTimeTypeFBTYPEFree/busy time type
InlineEncodingENCODINGInline encoding (BASE64)
LanguageLANGUAGELanguage
MembershipMEMBERGroup membership
ParticipationRoleROLEParticipation role (CHAIR, REQ-PARTICIPANT, etc.)
ParticipationStatusPARTSTATParticipation status (ACCEPTED, DECLINED, etc.)
RecurrenceIdentifierRangeRANGERecurrence range (THISANDPRIOR, THISANDFUTURE)
RelationshipTypeRELTYPERelationship type (PARENT, CHILD, SIBLING)
RsvpExpectationRSVPRSVP expectation (TRUE, FALSE)
SentBySENT-BYSent by
TimeZoneIdentifierTZIDTime zone identifier
ValueDataTypeVALUEValue data type (DATE, DATE-TIME, etc.)

Recurrence Types

Located in com.onixbyte.calendar.recurrence.

ClassDescription
FrequencyFrequency constants (DAILY, WEEKLY, MONTHLY, YEARLY) for recurrence rules
WeekdayNumWeekday number for recurrence rules (e.g., 2nd Monday)

Value Types

Located in com.onixbyte.calendar.value.

ClassDescription
FreeBusyTimeValueRepresents free/busy time value
PeriodOfTimeRepresents a period of time with start and end
PropertyValueBase value type for properties
UtcOffsetUTC offset value (e.g., -05:00, +01:00)

Formatted Output

All components and properties provide a formatted() method that returns an iCalendar-compliant string representation. The Calendar.formatted() method produces a complete .ics output wrapped in BEGIN:VCALENDAR/END:VCALENDAR.

String ics = calendar.formatted();
// BEGIN:VCALENDAR
// CALSCALE:GREGORIAN
// METHOD:PUBLISH
// ...
// END:VCALENDAR