views:

47

answers:

2

What's the best way to work out the time when my servlet in google app engine is hit ?

if I call System.currentTimeMillis() and store that info will it be reliable ?

I don't need milliseconds precision.

I just want to store an entity with the date on when it arrives.

Thanks

A: 

if I call System.currentTimeMillis() and store that info will it be reliable ?

Yes.

Nick Johnson
thanks Nick. How do you know ? empirical evidence ? found this somewhere in some google docs ?
Chez
Well, it's the system time. It's reliable and accurate, because the servers are kept in sync.
Nick Johnson
A: 

No, it won't be reliable.

In Dan Sanderson's book, "Programming Google App Engine" he says:

It's worth noting that App Engine makes no guarantees that the system clocks of all of its web servers are synchronized. <...> The server clock is not consistent enough as a source of time data for a real-world application, but it's good enough for this example.

http://books.google.com/books?id=6cL_kCZ4NJ4C&amp;lpg=PA25&amp;dq=clocks%20synchronized%20google%20app%20engine&amp;pg=PA25#v=onepage&amp;q=clocks%20synchronized%20google%20app%20engine&amp;f=false

hwiechers
Nick Johnson says that the clocks are synced. So I don't know if this is right.
hwiechers
let's assume he is not. what would it be a possible solution ?
Chez
In Python, you could use a DateTimeProperty on your model with auto_now_add=True.http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#DateTimePropertyI'm guessing there is a Java equivalent, but I don't know what it is.
hwiechers