Search code examples
javaandroidgoogle-mapstimegoogle-directions-api

Explaination of time format (Google Directions API)


I have read the documentation of the Google Directions API for making a direction request. An example of a URL is given as

http://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&sensor=false&departure_time=1343605500&mode=transit

The value of the departure_time variable is supposed to reflect the following information:

July 30, 2012 at 09:45 am.

Can someone please explain this time format.

Thanks.


Solution

  • It's a timestamp - seconds elapsed since the Unix epoch, 1970-01-01 00:00:00 UTC. If you want "right now" in that format, you can use System.currentTimeMillis() / 1000, or if you have a Date object, you can use date.getTime() / 1000.