将Calendar对象添加到ParseObject

时间:2015-09-05 12:05:34

标签: android parse-platform calendar android-calendar

我希望将Calendar对象添加到我创建的ParseObject中,但只要我尝试添加它就抛出异常:

ParseObject route = new ParseObject(ParseConstants.CLASS_ROUTES);
route.put(ParseConstants.KEY_ROUTE_PROPOSED_TIME, mProposedDateTime);


  09-05 12:57:55.735  16977-16977/com.khackett.runmate E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: com.khackett.runmate, PID: 16977
  java.lang.IllegalArgumentException: invalid type for value: class java.util.GregorianCalendar

我从前一个意图中获取Calendar对象,如下所示:

mProposedDateTime = (Calendar) getIntent().getSerializableExtra("proposedTime");

将Calendar对象添加到Parse的推荐方法是什么?

1 个答案:

答案 0 :(得分:2)

在Parse你需要一个 Date 对象,为此,你必须像这样调用getTime()route.put(ParseConstants.KEY_ROUTE_PROPOSED_TIME, mProposedDateTime.getTime());