public final class TimeZoneClient extends ClientBase<TimeZoneNetworkClient>
Calendar calendar = Calendar.getInstance(java.util.TimeZone.getTimeZone("UTC"));
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
TimeZoneClient client = TimeZoneClient.newInstance();
LatLng location = LatLng.fromDegrees(lat, lng);
ResponseFuture<TimeZone> timeZoneFuture = client.findTimeZone(location, calendar.getTimeInMillis());
timeZoneFuture.registerListener(new ResponseListener<TimeZone>() {
public void onResponse(TimeZone timeZone) {
// Use the updated time zone.
}
public void onError(ResponseException exception) {
// Handle errors.
}
});
// Don't forgot call shutdownNow.
// client.shutdownNow();
client
Modifier and Type | Method and Description |
---|---|
ResponseFuture<TimeZone> |
findTimeZone(LatLng latLng,
Long timeInMillis)
|
static TimeZoneClient |
newInstance()
Creates a new
TimeZoneClient . |
cancelAllActiveRequests, shutdown, shutdownNow
public static TimeZoneClient newInstance()
TimeZoneClient
.public ResponseFuture<TimeZone> findTimeZone(LatLng latLng, Long timeInMillis)
TimeZone
for the specified LatLng
and an optional time
for future DST calculation.
This request can throw the following exceptions:
HMTimeZoneNotFoundException
UserAuthenticationException
latLng
- is the request LatLng
to find a timezone.timeInMillis
- time in millis without any time zone shifting
Can be retrieve by set a Calendar
and call Calendar.getTimeInMillis()