public interface TimeService
Modifier and Type | Interface and Description |
---|---|
static interface |
TimeService.ConfigurationListener
The listener interface for receiving notifications when the time configuration of the device has changed (date,
time, time zone).
|
Modifier and Type | Method and Description |
---|---|
void |
addConfigurationListener(TimeService.ConfigurationListener listener)
Adds the given
TimeService.ConfigurationListener to the list of listeners that are notified when the time
configuration of the device has changed. |
long |
getCurrentTime()
Returns the current time.
|
String |
getTimeZoneId()
Returns the current time zone ID.
|
int |
getTimeZoneOffset()
Returns the current offset from UTC in seconds.
|
void |
removeConfigurationListener(TimeService.ConfigurationListener listener)
Removes the given
TimeService.ConfigurationListener to the list of listeners that are notified when the time
configuration of the device has changed. |
void |
setTimeConfiguration(long currentTime,
String zoneId,
int zoneOffset)
Sets the time configuration to use.
|
void addConfigurationListener(TimeService.ConfigurationListener listener)
TimeService.ConfigurationListener
to the list of listeners that are notified when the time
configuration of the device has changed.listener
- the new listener to addlong getCurrentTime()
String getTimeZoneId()
The zone ID is a string that represents either a region-based time zone or a fixed offset from UTC.
int getTimeZoneOffset()
The offset reflects the time zone and daylight saving time, applicable at the current instant.
void removeConfigurationListener(TimeService.ConfigurationListener listener)
TimeService.ConfigurationListener
to the list of listeners that are notified when the time
configuration of the device has changed.
Does nothing if the listener is not registered.
listener
- the listener to be removedvoid setTimeConfiguration(long currentTime, String zoneId, int zoneOffset)
currentTime
- the new time (in milliseconds, measured from the Java Epoch)zoneId
- the new time zone IDzoneOffset
- the new offset from UTC