admin管理员组文章数量:1277888
I'm writing a app that exposes a REST API. Some of the query parameters will be date/time (accurate to second), and some of the responses will be timestamps (accurate to millisecond).
The API implementation on the server is in Java. The client apps can be anything - java, javascript, .NET. The API returns XML or JSON data. Date/Time data is stored in a Oracle database.
Does anyone have remendations, based on prior pain, of what the best format format is for passing these date/time values. I'm thinking myself to just use a good old fashioned long to store the number of milliseconds since January 1, 1970, 00:00:00 GMT.
Edit The date range covered in the API is for real time events, so there will be nothing before 2010, and (setting myself up for abuse here) nothing after 2038.
I guess best would be determined by
a) Wide variety of languages support converting this long into internal date object, without having to write code to do it.
b) Lowest CPU overhead (on server app)
I'm writing a app that exposes a REST API. Some of the query parameters will be date/time (accurate to second), and some of the responses will be timestamps (accurate to millisecond).
The API implementation on the server is in Java. The client apps can be anything - java, javascript, .NET. The API returns XML or JSON data. Date/Time data is stored in a Oracle database.
Does anyone have remendations, based on prior pain, of what the best format format is for passing these date/time values. I'm thinking myself to just use a good old fashioned long to store the number of milliseconds since January 1, 1970, 00:00:00 GMT.
Edit The date range covered in the API is for real time events, so there will be nothing before 2010, and (setting myself up for abuse here) nothing after 2038.
I guess best would be determined by
a) Wide variety of languages support converting this long into internal date object, without having to write code to do it.
b) Lowest CPU overhead (on server app)
Share Improve this question edited Aug 24, 2010 at 16:33 Kevin asked Aug 24, 2010 at 16:02 KevinKevin 11.7k22 gold badges84 silver badges104 bronze badges1 Answer
Reset to default 9ISO 8601 all the way
Using any epoch-based method means you are bound to the range (in most systems) of a signed 32-bit INT (1901-12-13T20:45:52+00:00 through 2038-01-19T03:14:07+00:00) which, is really more of a timestamp than a date, since it can't handle far-reaching historical or future dates.
本文标签: javaRecommended date format for REST APIStack Overflow
版权声明:本文标题:java - Recommended date format for REST API - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741255611a2366614.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论