Menu

Text cannot be parsed to a Duration

2021-06-30
2021-06-30
  • Joerg Spiering

    Joerg Spiering - 2021-06-30

    On a Mac, a calendar entry with the reminder "alert at time of event" can be made.

    The parser throws an exception:
    net.fortuna.ical4j.data.ParserException: Error at line 51,940: Text cannot be parsed to a Duration
    at net.fortuna.ical4j.data.CalendarParserImpl.parse (CalendarParserImpl.java:158)
    at net.fortuna.ical4j.data.CalendarBuilder.build (CalendarBuilder.java:183)
    at net.fortuna.ical4j.data.CalendarBuilder.build (CalendarBuilder.java:171)
    ...

    Extract from the event:

    BEGIN:VALARM
    ACTION:AUDIO
    TRIGGER:PT
    ATTACH:Chord
    X-WR-ALARMUID:43F93F98-6524-4F9A-A1A8-02E9A18E4D3E
    END:VALARM
    

    The problem is the entry: TRIGGER:PT

    The CompatibilityHints.KEY_RELAXED_PARSING doesn't help.

    StringReader stringIn = new StringReader(myCalendarString);
    CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true);
    CalendarBuilder builder = new CalendarBuilder();
    calendar = builder.build(stringIn);
    

    How can I handle this problem elegantly?

     

    Last edit: Joerg Spiering 2021-06-30
  • Ben Fortuna

    Ben Fortuna - 2021-06-30

    It really is a malformed value for trigger. Even for zero time duration it should be PT0 or something like that. Can you confirm if this was produced from a known application?

    NOTE: I don't really monitor these forums regularly, so would suggest adding new issues over on github for tracking:

    https://github.com/ical4j/ical4j/issues

     

Log in to post a comment.