I\'m trying to send a DateTime
as a parameter to a method exposed over a WCF RESTful service with JSON encoding. The request looks like this:
POST h
This is code I use to send from Android Java to .NET WebApp. Create a JSON object with a date in the W3C XML schema:
Calendar myCalendarObj = Calendar.getInstance(); // Snap a moment in time
JSONObject jObj = new JSONObject(); // Create a JSON object (org.json.JSONObject)
SimpleDateFormat jsonDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); // from java.text.SimpleDateFormat
String senddate = jsonDateFormat.format(myCalendarObj.getTime());
jObj.put("a_date_field", senddate);