Skip to content

Token360/sntp-client-android

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

SNTPClient for Android

Simple SNTP client class for retrieving network time on Android (SNTPClient)

Copy-Paste

Copy the SNTPClient.java into your project, there you go. It's ready.

Usage

  1. Retrieve the time of a specific time zone.
SNTPClient.getDate(TimeZone.getTimeZone("Asia/Colombo"), new SNTPClient.Listener() {
    @Override
    public void onTimeReceived(String rawDate) {
        // rawDate -> 2019-11-05T17:51:01+0530
        Log.e(SNTPClient.TAG, rawDate);
    }

    @Override
    public void onError(Exception ex) {
        Log.e(SNTPClient.TAG, ex.getMessage());
    }
});

  1. Current time zone can be passed to retrive current time of the device zone.
Calendar.getInstance().getTimeZone();

About more

  • The output time is formatted according to ISO 8601 format.

yyyy-MM-dd'T'HH:mm:ssZ

  • Time server host is Google

time.google.com

About

Simple SNTP client class for retrieving network time on Android (SNTPClient)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%