Formatting a recurrence

maltaisn edited this page Jul 1, 2018 · 1 revision

Localized formatting

To convert a recurrence object to a readable and localized string, you can create a RecurrenceFormat object:

  • RecurrenceFormat(context, dateFormat): create a recurrence formatter.

    • context: any context
    • dateFormat: date format used to format end dates. Can be null at creation but mustn't be when formatting.
  • format(Recurrence r): format the recurrence r to a string.

RRule formatting

As of v1.3.0, you can convert recurrences to RFC 5545 compliant RRule string. For example, a weekly recurrence starting on January 1, 2018 and repeating on Sunday, Monday and Friday for 10 events becomes "DTSTART=20180101T000000;FREQ=WEEKLY;INTERVAL=1;BYDAY=SU,MO,FR;COUNT=5".

  • RRuleFormat.format(Recurrence r): format recurrence r to a RRule string. This method is static.

This format may be more easily applicable in other apps. In addition, they are many tools and libraries to parse them. However, it cannot be used to save the recurrence object to storage because the library provides no way to parse them any probably won't ever will. A way to save the recurrence would be parcelables or converting it to a byte array, see the wiki page Using the recurrence object for more information.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.