B4J Question Automatic Date and Time with NO Internet

Harris

Expert
Licensed User
Longtime User
My tablets are Wifi only.
I had to disable internet on the server because operators were abusing it. Only my app should run and I don't need all other apps updating themselves when never used antway.

The problem is: now clocks drift and have no way to sync with pool.ntp.org.

Anyone have a similar issue and resolved?

I can use GPS lib to get atomic time, compensate for timezone offset - BUT I must have user make the adjustment since setting it myself thru code is foreboden (the extent of my German)...

Like to here your comments.

Thanks

EDIT: This may get more hits in the Android section?

Edit2: Does anyone know what NTP a Samung tablet (Ative 8 - wifi only) uses? pool.ntp.org OR 2.adndroid.ntp.org? Or how deos one find out. Mr. Google does not seem to be helpful in this regard.
 
Last edited:

OliverA

Expert
Licensed User
Longtime User
However, if you can not set the time on the device with this (correct) server time, your hooped.
Maybe not. I think @MrKim's may be a hint towards a solution that you can control without the need for company involvement. It may be a tad convoluted, but it would be another choice. What you can do is keep your own time per device. First, get the device's time, then query the server's time. Figure out the offset. Use this offset any time for that device to determine the correct time for that device (in relations to the server). Now and then redo the time offset calculation to take care of any drifting of the devices clock (hourly, daily, more or less frequent, depending on how badly the clocks on the devices drift).

On the other hand, we may be totally over working this. If you happen to have constant server connection when you are creating database entries, then only let the server set any time entries in any insert/update queries, ignoring the devices time settings. Any time calculations should also be performed on the server, using the server times recorded in the database. I think this is what @MrKim is alluding to.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Maybe not. I think @MrKim's may be a hint towards a solution that you can control without the need for company involvement. It may be a tad convoluted, but it would be another choice. What you can do is keep your own time per device. First, get the device's time, then query the server's time. Figure out the offset. Use this offset any time for that device to determine the correct time for that device (in relations to the server). Now and then redo the time offset calculation to take care of any drifting of the devices clock (hourly, daily, more or less frequent, depending on how badly the clocks on the devices drift).

On the other hand, we may be totally over working this. If you happen to have constant server connection when you are creating database entries, then only let the server set any time entries in any insert/update queries, ignoring the devices time settings. Any time calculations should also be performed on the server, using the server times recorded in the database. I think this is what @MrKim is alluding to.
Yes, if I am simply recording the current time I use the Appropriate SQL function to get the time. Sometimes we need to calculate the hours between a previously recorded time and now so when I retrieve the record with the recorded time I will include in the query a request for the current time. Then I have what I need to do any math necessary without any additional round trips to the server.
For Example:
SELECT Tk_TimeIn, Tk_Hours, GETDATE() AS CurrentTime FROM TimeClock WHERE ....
I then use Tk_TimeIn and CurrentTime to calculate Tk_Hours.
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
My network is configured as follows:

My router get's the NTP time from Internet and act itself as NTP server for the net. Therefore my server and all clients (desktops, notebooks, tablets, ...) get the NTP time from the router.

Maybe a possible solution.
 
Upvote 0
Top