gpt4 book ai didi

java - 我的解析 StartTime 和 EndTime 没有正确连接到我的应用程序。帮助? ( java )

转载 作者:太空宇宙 更新时间:2023-11-03 11:08:51 24 4
gpt4 key购买 nike

我开发了一个预订应用程序,该应用程序的后端是通过 Parse 实现的。由于某种原因,Parse 中的更新信息与通过模拟器运行时应用程序中出现的信息完全不同。例如我的开始时间(日期)是 2015 年 4 月 14 日 19:00,我的结束时间(日期)是 2015 年 4 月 14 日 20:00。然而,当我运行该应用程序时,事件发生在不同的日期和时间。有人可以帮助我吗?

    private void makeWebCallToParse() {
ParseQuery<ParseObject> query = ParseQuery.getQuery("GymSession");
query.findInBackground(new FindCallback<ParseObject>() {

@SuppressWarnings("deprecation")
@Override
public void done(List<ParseObject> objects, ParseException e) {
if(e == null) {
for(int i = 0; i < objects.size(); i++) {
WeekViewEvent event = new WeekViewEvent();
event.setName(objects.get(i).getString("GymSession"));
event.setId(i);

event.setParseObjectId(objects.get(i).getObjectId());

Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, objects.get(i).getDate("StartTime").getDay());
cal.set(Calendar.DAY_OF_MONTH, objects.get(i).getDate("StartTime").getMonth());
cal.set(Calendar.DAY_OF_YEAR, objects.get(i).getDate("StartTime").getYear());
cal.set(Calendar.MINUTE, objects.get(i).getDate("StartTime").getMinutes());
cal.set(Calendar.HOUR, objects.get(i).getDate("StartTime").getHours());
event.setStartTime(cal);

Calendar calEnd = Calendar.getInstance();
calEnd.set(Calendar.DAY_OF_WEEK, objects.get(i).getDate("EndTime").getDay());
calEnd.set(Calendar.DAY_OF_MONTH, objects.get(i).getDate("EndTime").getMonth());
calEnd.set(Calendar.DAY_OF_YEAR, objects.get(i).getDate("EndTime").getYear());
calEnd.set(Calendar.MINUTE, objects.get(i).getDate("EndTime").getMinutes());
calEnd.set(Calendar.HOUR, objects.get(i).getDate("EndTime").getHours());
event.setEndTime(calEnd);

event.setColor(getResources().getColor(R.color.event_color_01));
eventsWeb.add(event);
}
}
}
});
}

最佳答案

您可以使用 beforeSave 云方法来匹配时间。

Parse.Cloud.beforeSave("YourClassName", function(request, response) { 
request.object.set("yourDateField", new Date());
response.success();
});

这将在将行插入到类中之前使用服务器时间戳 (GMT) 设置“yourDateField”。

更多详情:parse cloud code guide

关于java - 我的解析 StartTime 和 EndTime 没有正确连接到我的应用程序。帮助? ( java ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29685235/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com