DTSTART parsing in caldav4j

36 views
Skip to first unread message

Tobias Rodehutskors

unread,
Feb 22, 2012, 4:58:07 PM2/22/12
to caldav4j
Hi!

I have found the caldav4j project and i want to use it to sync my
android
phone with my ownCloud instance. But there is a problem.

Some of my events use the following DTSTART format in the ics file:

DTSTART;VALUE=DATE:20081025

This is allowed in order to the rfc.

But caldav4j can only parse the following DTSTART format:

DTSTART:20090302T090000Z


I have found this issue by looking at the log cat output:

02-22 21:07:16.377: W/System.err(24328):
java.lang.StringIndexOutOfBoundsException
02-22 21:07:16.377: W/System.err(24328): at
java.lang.String.substring(String.java:1651)
02-22 21:07:16.377: W/System.err(24328): at
com.android.calendar.caldav.CalDAVService.parseDateTimeToMillis(CalDAVService.java:
560)


The source code in
http://code.google.com/p/caldav4j/source/browse/android/src/com/android/calendar/caldav/CalDAVService.java
is this:

private long parseDateTimeToMillis (String date, String tzid) {
GregorianCalendar cal = new
GregorianCalendar(Integer.parseInt(date.substring(0, 4)),
Integer.parseInt(date.substring(4, 6)) - 1,
Integer.parseInt(date.substring(6, 8)),
Integer.parseInt(date.substring(9, 11)),
Integer.parseInt(date.substring(11, 13)),
Integer.parseInt(date.substring(13, 15)));
TimeZone tz = TimeZone.getTimeZone (tzid);
cal.setTimeZone(tz);
return cal.getTimeInMillis ();
}

The same problem will arise for DTEND.

Do you have any kind of workaround for this problem? For example a
converter
which converts the first format into the second one for an ics file?

regards, Tobias
Reply all
Reply to author
Forward
0 new messages