我正在尝试在 Google 日历中设置 Activity 的开始日期,但它始终采用错误的值。 代码
EventDateTime start = new EventDateTime();
EventDateTime end = new EventDateTime();
SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-DD'T'hh:mm:ss.SSS'Z'");
Date dt = new Date();
Date endDate = new Date();
dt = df.parse("2015-05-23T09:00:00.000Z");
endDate = df.parse("2015-05-25T09:30:00.000Z");
start.setDateTime(new DateTime(dt));
end.setDateTime(new DateTime(endDate));
但是变量“end”和“start”分别采用值“2014-12-28T09:30:00.000+05:30”和“2014-12-28T09:00:00.000+05:30”。 我的时区是 GMT+5:30 。
最佳答案
因为它应该是: yyyy-MM-dd
而不是 YYYY-MM-DD
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS'Z'");
在这里您可以找到符号 int SimpleDateFormat 的含义:
http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
大的 DD
是一年中的某一天,小dd
是一月中的某天。
关于java - 在谷歌日历事件中设置日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30431762/