Post

3 followers Follow
0
Avatar

Android create item with date field

Hello all,

I'm having some trouble creating an item. The specific problem lies with the external-id "date" which can take multiple arguments (start, start_date, end etc).

I'm using the Android SDK, and have tried every way of formatting it that I can think of, but with no luck - I keep getting the error that says

"A value is required for either 'start', 'start_date' or 'start_utc'"

I've tried the following things:

item.addValue("date","start_date: 2016-03-17");
item.addValue("date", "{\"start\":\"2016-03-17 11:27:10\",\"end\":\"2016-03-17 11:27:11\"}");
item.addValue("date", "{\"start_date\":\"2016-03-17\"}");
item.addValue("start", "2016-03-17 11:27:10");
item.addValue("start_date","2016-03-17");
try {
jsonDate = new JSONArray();
JSONObject startDate = new JSONObject("{\"start\":\"2016-03-17 11:27:10\"}");
JSONObject endDate = new JSONObject("{\"end\":\"2016-03-17 11:27:11\"}");
jsonDate.put(startDate);
jsonDate.put(endDate);
item.addValue("date", jsonDate);
} catch (JSONException e) {
e.printStackTrace();
}
try {
jsonDate = new JSONArray();
JSONObject startDate = new JSONObject("{\"start_date\":\"2016-03-17\"}");
jsonDate.put(startDate);
item.addValue("date", jsonDate);
} catch (JSONException e) {
e.printStackTrace();
}

It's the only thing I need before I'm able to finish my app, so any help would be much appreciated! Thanks :-)

Jesper Halborg Madsen

Please sign in to leave a comment.

1 comment