【问题标题】:How to Add minute to EventdateTime and convert to DateTime如何将分钟添加到 EventdateTime 并转换为 DateTime
【发布时间】:2019-05-21 14:39:10
【问题描述】:

我正在使用 Google API,我需要将分钟添加到 EventDateTime 并以 DateTime 格式发回。

req.setTimeMin(start.getDateTime());

start 是一个 EventDateTime,我可以使用 getDateTime 将其转换为 Datetime。

但我不能DateTime end = start.getDateTime().plusMinutes(30)

我做错了什么?

【问题讨论】:

标签: java android time google-calendar-api date


【解决方案1】:

您可以通过使用以毫秒为单位的值来实现此目的:

import com.google.api.client.util.DateTime;
import com.google.api.services.calendar.model.EventDateTime;

...

DateTime end = new DateTime(start.getDateTime().getValue() + 30L * 60L * 1000L);

【讨论】:

  • 嗬嗬!!你救了我上吊的日子!谢谢
  • @RaphaelObadia 很高兴它有帮助。
猜你喜欢
  • 1970-01-01
  • 2015-03-13
  • 1970-01-01
  • 2014-12-30
  • 2010-11-29
  • 2020-05-01
  • 2011-06-08
  • 1970-01-01
  • 2010-11-13
相关资源
最近更新 更多