且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Android发布DateTime到WCF RESTful JSON服务

更新时间:2023-11-07 23:20:58

发布日期到WCF服务的正确格式是:
/ Date(53244000000)/
其中括号中的数字是自1970年UTC午夜以来的毫秒数。

The correct format for posting dates to WCF service is using: /Date(53244000000)/ where the number in brackets is the number of milliseconds since 1970 UTC Midnight.

Date dt = new Date();
long date = Date.UTC(dt.getYear(), dt.getMonth(), dt.getDay(), dt.getHours(),dt.getMinutes(), dt.getSeconds());
String senddate = "/date("+date+")/";

然后使用它如下

inputparam.put("DateTime", datetime);