简体   繁体   English

GAE-GWT中日期数据字段类型的最佳做法是什么?

[英]What is best practice for date data field type in GAE-GWT?

This question has few sub-questions! 这个问题有几个子问题!

  1. What is best data type for storing date? 什么是存储日期的最佳数据类型? java-s Date, or just long - in miliseconds, formated String? java-s日期,还是长-以毫秒为单位,格式化的字符串?
  2. Client/Server time-zone problem 客户端/服务器时区问题

    a) How to show date on client side (correct time zone) a)如何在客户端显示日期(正确的时区)

    b) If client inserts date, server needs to insert date in servers timezone or better fixed app timezone? b)如果客户端插入日期,服务器需要在服务器时区或更固定的应用程序时区中插入日期? (correct api?) (正确的API?)

  3. Sorting is easy with long data type, but is it working with Date? 对于长数据类型,排序很容易,但是可以与Date一起使用吗?
  4. Manipulating (for example select records for last 4 days, or between two dates, etc...). 操作(例如,选择最近4天或两个日期之间的记录,等等)。

Is there any good manual for this topic! 这个主题有什么好的手册!

Currently, I am using long for date data type, but it somehow does't feel right (for example browsing in admin console is confusing). 目前,我正在使用long for date数据类型,但感觉不对(例如,在管理控制台中浏览会造成混淆)。 Thanks! 谢谢!

  1. java.util.Date is a supported type java.util.Date是受支持的类型
  2. How you show this to the user is a more generic java problem. 您如何向用户显示此问题是一个更通用的Java问题。 All dates are stored in UTC. 所有日期都存储在UTC中。 I suggest you take a look at joda-time for handling timezones and dates. 我建议您看一下joda-time来处理时区和日期。
  3. Yes, sorting of Date objects is supported in queries etc. 是的,查询等支持Date对象的排序。
  4. Filtering is also supported, eg, date > yesterday && date < today. 还支持过滤,例如,日期>昨天&&日期<今天。 Don't forget to bear in mind there are limitations when you impose filters. 施加过滤器时,请不要忘记记住一些限制。 For example, those inequality filters can only apply to one property at a time. 例如,这些不等式过滤器一次只能应用于一个属性。 See restrictions on queries 查看查询限制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM