Displaying updated ntp time in java -


i writing ntp client , server in java. calculating offset , round trip delay using ntp timestamps. should point out calculating these seconds (first 32 bits) , fractions (second 32 bits) separately. getting offset results such 0 seconds , 1859395165 fractions.

my question how can use these offsets print out system time if adjusted according given offset?

i thinking add fractions onto fractions part of timestamp systems current time, if sum of fractions greater 1 second believe encounter problems seconds incorrect.

you convert fraction milliseconds first , calculations. lets time 11:05:21:900 server , offset 200 ms. add 11:05:21:900 , 11:05:22:100.

you need function checks if hit new second/minute/etc after adding offset. start of code this.

systemms += offsetms; if (systemms >= 1000) {     systems += 1;     systemms -= 1000;     if (systems >= 60)     {         etc     } } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -