Class TimeService

All Implemented Interfaces:
CtxEventListener, ContextHandleAware, HandleAware, Ready, ReadyListener

public final class TimeService extends AbstractService
Tracks time changes, time drift and generates time related events.
Since:
1.0
Version:
2023-03-06
  • Field Details

  • Method Details

    • setTime

      public void setTime(int hour, int min, int sec)
      Set the time for the entire device. This will update the time on all nodes within the device. Use the TimeChangeListener interface to react to time changes as time may not be set in the entire device by the time this method returns.
      Parameters:
      hour - hour: 0..23
      min - minutes: 0..59
      sec - seconds: 0..59
    • setDate

      public void setDate(int month, int day, int year)
      Set the date for the entire device. This will update the date on all nodes within the device. Use the TimeChangeListener interface to react to date changes as date may not be set in the entire device by the time this method returns.
      Parameters:
      month - month of year: 0..11
      day - day of month: 1..31
      year - year: full year
    • setTimeZone

      public void setTimeZone(String timeZone)
      Set the timezone for the entire device. This will update the timezone on all nodes within the device. Use the TimeZoneChangeListener interface to react to timezone changes as timezone may not be set in the entire device by the time this method returns.

      Setting the timezone will update the timezone in linux as well as all running jvm's. Other processes may not receive updated timezone information as there is not a standard mechanism to notify all processes in linux of a timezone change and timezone is typically cached in the TZ environment variable when linux processes starts.

      Parameters:
      timeZone - linux timeZone name
    • getTimeZone

      public String getTimeZone()
      Return the current timeZone in effect. This is the timeZone from the linux filesystem and should be reflected in the default jvm timeZone.