TrueTime for Android

Additional

Language
Java
Version
3.4 (Sep 6, 2018)
Created
Jul 9, 2016
Updated
Jun 10, 2019
Owner
Instacart (instacart)
Contributors
Ravindra Kumar (ravidsrk)
Maksim Golivkin (mataanin)
Kaushik Gopal (kaushikgopal)
Niklas Baudy (vanniktech)
John Carlson (Jawnnypoo)
TonyTangAndroid
npace
dladowitz
msanders
shaunpanjabi
eranpolo
sveltema
erluxman
shields
ztang-zz
15
Activity
Badge
Generate
Download
Source code
APK file

Show card

TrueTime for Android

Make sure to check out our counterpart too: TrueTime, an NTP library for Swift.

NTP client for Android. Calculate the date and time "now" impervious to manual changes to device clock time.

In certain applications it becomes important to get the real or "true" date and time. On most devices, if the clock has been changed manually, then a new Date() instance gives you a time impacted by local settings.

Users may do this for a variety of reasons, like being in different timezones, trying to be punctual by setting their clocks 5 – 10 minutes early, etc. Your application or service may want a date that is unaffected by these changes and reliable as a source of truth. TrueTime gives you that.

You can read more about the use case in our blog post.

In a recent conference talk, we explained how the full NTP implementation works with Rx. Check the video and slides out for implementation details.

Also, once we have this information it's valid until the next time you boot your device. This means if you enable the disk caching feature, after a single successful NTP request you can use the information on disk directly without ever making another network request. This applies even across application kills which can happen frequently if your users have a memory starved device.

Installation

See the wiki instructions.

Wiki has a lot of useful information

Take a look at the wiki sidebar which should have a lot of useful information.

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.