public class NtpTimeProvider extends java.lang.Object implements TimeProvider
Constructor and Description |
---|
NtpTimeProvider(java.net.InetAddress host,
java.util.concurrent.ScheduledExecutorService scheduledExecutorService) |
Modifier and Type | Method and Description |
---|---|
org.ros.message.Time |
getCurrentTime() |
void |
startPeriodicUpdates(long period,
java.util.concurrent.TimeUnit unit)
Starts periodically updating the current time offset periodically.
|
void |
stopPeriodicUpdates()
Stops periodically updating the current time offset.
|
void |
updateTime()
Update the current time offset from the configured NTP host.
|
public NtpTimeProvider(java.net.InetAddress host, java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
host
- the NTP host to usepublic void updateTime() throws java.io.IOException
java.io.IOException
public void startPeriodicUpdates(long period, java.util.concurrent.TimeUnit unit)
The first time update happens immediately.
Note that errors thrown while periodically updating time will be logged but not rethrown.
period
- time between updatesunit
- unit of periodpublic void stopPeriodicUpdates()
public org.ros.message.Time getCurrentTime()
getCurrentTime
in interface TimeProvider