Bug in 'add Date to DateList'

  • Tom Deschepper

    Tom Deschepper - 2010-05-11

    When I add a DateTime 'date' to a DateList, the timezone of date is set to null.

    Can easly be solved by taking a clone before adding but if it's a bug, I just wanted to let you know.

    public void addExDate(net.fortuna.ical4j.model.Date date) {
            if (event.getProperty(Property.EXDATE) == null) {
                ExDate exdate = new ExDate();
                if (date instanceof DateTime) {
                    if (((DateTime) date).isUtc()) {
                        exdate.setUtc(((DateTime) dateclone).isUtc());
                    } else {
                        exdate.setTimeZone(((DateTime) date).getTimeZone());
            } else {
                ((ExDate) event.getProperty(Property.EXDATE)).getDates().add(date);


  • Alexander Klimetschek

    You can initialize the date list, before adding dates. This is what I am doing:

        private static DateList createDateList(boolean isDate, TimeZone timeZone) {
            DateList dateList;
            if (isDate) {
                dateList = new DateList(net.fortuna.ical4j.model.parameter.Value.DATE);
            } else {
                dateList = new DateList(net.fortuna.ical4j.model.parameter.Value.DATE_TIME);
            if (timeZone != null && TimeZones.isUtc(timeZone)) {
            } else {
            return dateList;

    And then with ExDate:

    DateList exceptionList = createDateList(isDate, timeZone);
    // add dates to list
    ExDate date = new ExDate(exceptionList);



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks