Package com.tccc.kos.core.service.time
Class TimeService
java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.commons.core.service.AbstractService
com.tccc.kos.core.service.time.TimeService
- All Implemented Interfaces:
CtxEventListener,ContextHandleAware,HandleAware,Ready,ReadyAndReadyListener,ReadyListener
Tracks time changes, time drift and generates time related events.
- Since:
- 1.0
- Version:
- 2023-03-06
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturn the current timeZone in effect.voidsetDate(int month, int day, int year) Set the date for the entire device.voidsetTime(int hour, int min, int sec) Set the time for the entire device.voidsetTimeZone(String timeZone) Set the timezone for the entire device.Methods inherited from class com.tccc.kos.commons.core.service.AbstractService
getHandle, getHandlePrefixMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tccc.kos.commons.core.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompletedMethods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPathMethods inherited from interface com.tccc.kos.commons.util.ready.ReadyAndReadyListener
onBeanReady, onDependenciesReadyMethods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Field Details
-
TOPIC_TIME_CHANGE
- See Also:
-
TOPIC_DAY_CHANGE
- See Also:
-
TOPIC_TIMEZONE_CHANGE
- See Also:
-
-
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 theTimeChangeListenerinterface 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..23min- minutes: 0..59sec- 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 theTimeChangeListenerinterface 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..11day- day of month: 1..31year- year: full year
-
setTimeZone
Set the timezone for the entire device. This will update the timezone on all nodes within the device. Use theTimeZoneChangeListenerinterface 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
Return the current timeZone in effect. This is the timeZone from the linux filesystem and should be reflected in the default jvm timeZone.
-