Android Get Timezone From GPS Location

Jan 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!!)?.zoneIdval 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:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.