devng / twig-persist

Automatically exported from code.google.com/p/twig-persist
0 stars 0 forks source link

Date Comparisons not Working #69

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Save a java.util.Date() property in a bean.
2. Search for that bean with Twig like this...

Iterator<Event> i = ourDatastore.find().type(Event.class)
    .addFilter("startDate", FilterOperator.GREATER_THAN_OR_EQUAL, new Date())
    .addSort("startDate", SortDirection.ASCENDING)
    .fetchMaximum(3)
    .now();

What is the expected output? What do you see instead?

I would expect our bean to be found anytime the "startDate" property is greater 
than current local time.

If we set the "startDate" property to more than 5 hours in the future, it 
returns a value. If we set it to less than 5 hours in the future, it will not 
find our bean.

This issue can be recreated doing a "greater than", and a "less than".

What version of the product are you using? On what operating system?
2.0, Beta 5
OSX 10.7

Please provide any additional information below.

After we get the bean out, the startDate object does appear to have the correct 
time.

We are -5 from UTC which can't be a coincidence, right? I'm thinking that when 
we do a search it's not converting our "new Date()" to UTC before doing the 
comparison.

Thanks in advance.

Original issue reported on code.google.com by rmannin...@gmail.com on 1 Aug 2011 at 7:10

GoogleCodeExporter commented 8 years ago
Nothing fancy is done with storing dates. It is up to your application to make 
sure dates are created using the correct time zone.  You will be able to see 
the stored value by looking in the datastore viewer (production only).  
Remember that a Date is just a long value that does not know about time zones. 

Original comment by jdpatterson on 2 Aug 2011 at 5:49

GoogleCodeExporter commented 8 years ago
Yep, it turned out the GAE server thinks it's in UTC, so when we created a date 
by parsing a string it was off. Thanks for you help.

Original comment by rmannin...@gmail.com on 2 Aug 2011 at 10:29

GoogleCodeExporter commented 8 years ago
Feel free to close this as it was definitely my error. :)

Original comment by rmannin...@gmail.com on 18 Aug 2011 at 7:12

GoogleCodeExporter commented 8 years ago

Original comment by jdpatterson on 8 Sep 2011 at 3:14