Taking a step back, I should say that if you're using java.util.Date
with timezone info, "you're doing it wrong".  java.util.Date is a
trainwreck, and any methods that affect an internal notion of a TZ
have been deprecated.  If you care about timezones, using Date is a
mistake - it's best to think of Date as purely a wrapper for
millis-since-epoch, nothing more.

I strongly recommend purging java.util.Date from your code and using
Joda Time instead.  You can use DateTime to represent an instant (and
set TZ if you want to format it for a locale) or you can use
LocalDateTime to store an abstract notion of a time without a TZ -
which, if you're taking a date as user input, is often what you really
want to persist.

Jeff

On Wed, Jan 25, 2012 at 2:17 PM, Matthew Jaggard <matt...@jaggard.org.uk> wrote:
> You could create a sortable date format string. For example, convert the
> date to GMT and store it yyyy-mm-dd hh:mm:ss.nnn then store the timezone
> afterwards so you can convert back to the date/time in the timezone.
>
> On 25 Jan 2012 19:05, "Kesava Neeli" <nke...@gmail.com> wrote:
>>
>> Thanks. That's what I was doing for some date fields now. Store the date
>> in a well formatted string and then do conversions. But it becomes tough
>> when you want to build a query "get me all records in last day" and the
>> datastore for that object contains thousands of  records. With the strings,
>> you need to iterate through all records, get a date and then do a
>> comparison.
>>
>> With "date" data type, you can rely on appengine to return correct data.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Java" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/google-appengine-java/-/7sg4mVI55SMJ.
>> To post to this group, send email to
>> google-appengine-java@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-appengine-java+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to google-appengine-java@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to