0
votes

Currently working in Google Map App.I want to use Google transit API in android application. I am using like this.

http://maps.googleapis.com/maps/api/directions/json?origin=77.589355,13.004558&destination=78.655758,11.253837&mode=transit&sensor=false&region=fr&departure_time=1387069950

What is departure_time? How can I find. All the details I'm getting dynamically(the user choices).

<li>
    String url = "http://maps.googleapis.com/maps/api/directions/xml?" + 
                 "origin=" + start.latitude + "," + start.longitude + 
                 "&destination=" + end.latitude + "," + end.longitude + 
                 "&sensor =false &units=metric&mode=trnsit......."
</li>

like this I'm using.

Can anyone please help me with

  • How can I find departure time dynamically and
  • where can I get?
1

1 Answers

0
votes

The format you are looking for is the number of seconds elapsed since 1st January 1970, sometimes called "Unix time".

The Date class includes the getTime method to get this value. Try something like this:

import java.util.*;

Date departure = new Date();  // This is the current time for testing purposes

String url = "http://maps.googleapis.com/maps/api/directions/xml?origin=" +
    start.latitude + "," + start.longitude + "&destination=" + end.latitude +
    "," + end.longitude + "&mode=transit&sensor=false&region=fr&departure_time=" +
    departure.getTime();