How Can I Know Time In A Specific Country If I Am In A Differenet Country?
Solution 1:
You can use Joda-Time library,
http://www.joda.org/joda-time/
How can i know time in a specific country if i am in a differenet country?
http://www.joda.org/joda-time/apidocs/index.html
You can get the DateTimeZone depending on the Canonical ID defined in the Joda Time,
DateTimeZonezone= DateTimeZone.forID("Asia/Kolkata");
Joda Time has a complete list of Canonical ID from where you can get TimeZone depending on the Canonical ID.
So, if you want to get the local time in New York at this very moment, you would do the following
//getcurrent moment indefaulttime zone
DateTime dt =new DateTime();
// translate toNew York localtime
DateTime dtNewYork = dt.withZone(DateTimeZone.forID("America/New_York"));
here it is explained very perfectly which is my reference to your question
Get time of different Time zones on selection of time from time picker
and you can also use this link without getting use of api
http://tutorials.jenkov.com/java-date-time/java-util-timezone.html
other references
How to get time with respect to another timezone in android
Date and time conversion to some other Timezone in java
How to convert date time from one time zone to another time zone
Solution 2:
x is the time zone id, there are a link of a list of them. Only need to feed the gettimeZone("with the time zone id") with the time zone of the city you want to know the time (I'm saying city because there are country with a lot of time zones like US or Russia).
TimeZone tz = TimeZone.getTimeZone("x")
http://garygregory.wordpress.com/2013/06/18/what-are-the-java-timezone-ids/
Post a Comment for "How Can I Know Time In A Specific Country If I Am In A Differenet Country?"