简体   繁体   中英

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?
  2. Client/Server time-zone problem

    a) How to show date on client side (correct time zone)

    b) If client inserts date, server needs to insert date in servers timezone or better fixed app timezone? (correct api?)

  3. Sorting is easy with long data type, but is it working with Date?
  4. Manipulating (for example select records for last 4 days, or between two dates, etc...).

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). Thanks!

  1. java.util.Date is a supported type
  2. How you show this to the user is a more generic java problem. All dates are stored in UTC. I suggest you take a look at joda-time for handling timezones and dates.
  3. Yes, sorting of Date objects is supported in queries etc.
  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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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