com.intel.util
Class Calendar
- java.lang.Object
-
- com.intel.util.Calendar
-
public abstract class Calendar extends java.lang.Object
This abstract class provides methods that applications can use to create their own notion of time. It is a factory class that allows creating instances of the following calendar types:-
CLOCK_SOURCE_PRTC
- Based on the secure time - Protected Real Time Clock.
-
-
-
Field Summary
Fields Modifier and Type Field and Description static byte
CLOCK_SOURCE_PRTC
Calendar instances created with this clock source will configure their time based on secure time - Protected Real Time Clock.static byte
SET_TIME_INFO_LENGTH
The size that must be used for theset_time_info
array when calling thesetTime
method.
-
Method Summary
Methods Modifier and Type Method and Description static Calendar
getInstance(byte clock_source, TimeZone zone)
Creates aCalendar
instance that will use the specified clock source.abstract int
getTime(byte[] set_time_info, int offset)
Gets the current time of thisCalendar
instance.abstract void
setTime(int time, byte[] set_time_info, int offset)
Sets the time for thisCalendar
instance.abstract void
setTimeZone(TimeZone zone)
Updates the time zone used by thisCalendar
instance.
-
-
-
Field Detail
-
CLOCK_SOURCE_PRTC
public static final byte CLOCK_SOURCE_PRTC
Calendar instances created with this clock source will configure their time based on secure time - Protected Real Time Clock.- See Also:
- Constant Field Values
-
SET_TIME_INFO_LENGTH
public static final byte SET_TIME_INFO_LENGTH
The size that must be used for theset_time_info
array when calling thesetTime
method.- See Also:
setTime
description for more details., Constant Field Values
-
-
Method Detail
-
getInstance
public static final Calendar getInstance(byte clock_source, TimeZone zone) throws UtilException
Creates aCalendar
instance that will use the specified clock source.- Parameters:
clock_source
- defines the clock source for the created instance. The available sources are:-
CLOCK_SOURCE_PRTC
-
zone
- defines theTimeZone
to be used along with this instance. This parameter must be set forCLOCK_SOURCE_PRTC
.- Returns:
- The
Calendar
instance based on the specified clock source. - Throws:
IllegalParameterException
- in the following cases:- If the clock source is CLOCK_SOURCE_PRTC and zone is null.
- If the clock source specified is invalid.
UtilException
-
setTimeZone
public abstract void setTimeZone(TimeZone zone) throws UtilException
Updates the time zone used by thisCalendar
instance.- Parameters:
zone
- the new Time zone to be used with thisCalendar
- Throws:
IllegalParameterException
- when this method is used on an instance based on calendar typeCLOCK_SOURCE_PRTC
and the zone is null.UtilException
-
setTime
public abstract void setTime(int time, byte[] set_time_info, int offset) throws UtilException
Sets the time for thisCalendar
instance. Calling this method has no impact on the time of any applet except the caller applet. Upon return, the caller receives the configured time meta-data (which includes an applet offset from the secure time and the current secure time version). This data must be saved by the applet (for example, in hard drive storage) and used as input in any subsequent calls to thegetTime
method.- Parameters:
time
- the current time in UNIX timestamp format (number of seconds elapsed since January 1, 1970)set_time_info
- a byte array that, when returned, holds the meta-data of this time configuration. The method will write into the array the meta_data of this time configuration whose size isSET_TIME_INFO_LENGTH
bytes. The applet does not need to know the internal structure of this data.offset
- the offset in theset_time_info
array- Throws:
IllegalParameterException
- when the time is invalid (earlier than the current PRTC time, or a number which is more than the number of seconds elapsed between 1970 and 2030).UtilException
- in case of an internal error.
-
getTime
public abstract int getTime(byte[] set_time_info, int offset) throws UtilException
Gets the current time of thisCalendar
instance. If aTimeZone
instance was configured for thisCalendar
instance, the time zone offset is added to the time base of thisCalendar
instance and returned as the current time by this method.- Parameters:
set_time_info
- the byte array holding time configuration meta-data that was received from thesetTime
method.offset
- the offset in the set_time_info array which points to the beginning of the set_time_info data.- Returns:
- The current time in UNIX timestamp format (number of seconds elapsed since January 1, 1970).
If a
TimeZone
instance was configured for thisCalendar
instance, the time zone offset will be added to the time base. If this method is used on an instance based on the calendar typeCLOCK_SOURCE_PRTC
without first calling thesetTime
method, the behavior is not defined and an exception of typeMeException
might be thrown. - Throws:
IllegalParameterException
- whenset_time_info
is invalid (for example, the offset from PRTC time is invalid, or the version is different from the current PRTC version due to RTC reset). In such cases calling thesetTime
method again might resolve the problem.UtilException
- in case of an internal error.
-
-