Android library for time stamping using NTP Protocol.
Based on Instacart's TrueTime library with patch from https://github.com/martinfilipekcz/truetime-android.git
Re-factored, reduce and re-implemented in Kotlin.
Java's System.currentTimeMillis is not reliable for timestamping, prone to user configuration changes to the device. Using NTP Protocol to get current time is more reliable.
dependencies {
...
implementation 'id.zeheater.realtimestamp:realtimestamp:0.1-alpha'
...
}
Initialize the library by subclassing your application
class SampleApp : Application() {
companion object {
object Rtc : RealTimeStamp()
}
override fun onCreate() {
super.onCreate()
Rtc.init(this@SampleApp)
}
}
SampleApp.Companion.Rtc.now("yyyy-MM-dd HH:mm:ss")