TimeZoneMap (Offline)
This is an offline solutions with 2 main drawbacks
- Will increase APK size by 10MB (Might want to consider Android App Bundle Dynamic Feature Modules)
- Initialization of the library could take 3-6 seconds
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: