Android Get Timezone From GPS Location

January 14, 2020

TimeZoneMap (Offline)

This is an offline solutions with 2 main drawbacks

Dependencies

dependencies {
    implementation('us.dustinj.timezonemap:timezonemap:4.0') {
        // Exclude standard compression library
        exclude group: 'com.github.luben', module: 'zstd-jni'
    }
    implementation 'com.github.luben:zstd-jni:1.4.4-3@aar'
}

Usage

val timeZoneMap = TimeZoneMap.forEverywhere()

val zoneId = timeZoneMap.getOverlappingTimeZone(lat!!, lon!!)?.zoneId

val timezone = if (zoneId == null)
        ZoneId.systemDefault()
    else
        ZoneId.of(zoneId)

Google Maps Time Zone API (Online)

https://developers.google.com/maps/documentation/timezone/start

Price: 5.00 USD per 1000 request, with $200 free credits per month

https://developers.google.com/maps/billing/gmp-billing#time-zone

Refer Google Timezone API (Python).

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.