【问题标题】:ical4j keeps losing the Z at the end of exdateical4j 在 exdate 结束时不断丢失 Z
【发布时间】:2015-10-28 16:54:45
【问题描述】:

Ical4j Exdate 属性拒绝从 ical 文件解析的 utc EXDATE 末尾的 Z。如何让它保留 Z。我尝试删除 EXDATE 并设置具有所需格式的新 EXDATE,但它仍然不起作用并且 Z 仍然被拒绝。请在下面找到我编写的代码:

Iterator<Property> iterator = cal.getComponents().get(0).getProperties().iterator(); 
//This iterator iterates over the properties of the one component in a parsed out calendar "cal"

DateList list = new DateList(net.fortuna.ical4j.model.parameter.Value.DATE_TIME);
while (iterator.hasNext()) {
      Property p = iterator.next();
      if (p.getName().equals("EXDATE")) {

                StringBuilder value = new StringBuilder(p.getValue());
                value.append("Z");
                System.out.println("New ExDate :" + value.toString());
                Date date = new Date(value.toString(), "yyyyMMdd'T'hhmmss'Z'");
                list.add(date);
                iterator.remove();
      }
}
if (!list.isEmpty()) {
      cal.getComponents().get(0).getProperties().add(new ExDate(list));
}
for (final Property p : cal.getComponents().get(0).getProperties()) {
            System.out.println(p.getName() + ":" + p.getValue());
}

得到的结果是格式 EXDATE:20151117T190000,20151118T190000

我如何让它在“20151117T190000Z”之类的时间戳末尾保留 Z,因为它导致我的客户不理解 exdate 并完全忽略它。这些值在客户端从那里拉取之前存储在 caldav 服务器中

【问题讨论】:

    标签: icalendar ical4j


    【解决方案1】:

    您是否尝试在 DateList 上执行 setUtc(true) ?

    【讨论】:

    • 是的,我做到了,它仍然不断丢失 Z
    猜你喜欢
    • 2018-10-15
    • 1970-01-01
    • 1970-01-01
    • 2018-11-22
    • 2010-11-04
    • 1970-01-01
    • 2016-11-30
    • 2021-02-28
    • 2011-08-20
    相关资源
    最近更新 更多