Intel

Developer Zone

Calendar

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.
    Note that this class enables different applets to configure their own time without impacting the time of other applets, or other entities using the secure 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 the set_time_info array when calling the setTime method.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      static Calendar getInstance(byte clock_source, TimeZone zone)
      Creates a Calendar instance that will use the specified clock source.
      abstract int getTime(byte[] set_time_info, int offset)
      Gets the current time of this Calendar instance.
      abstract void setTime(int time, byte[] set_time_info, int offset)
      Sets the time for this Calendar instance.
      abstract void setTimeZone(TimeZone zone)
      Updates the time zone used by this Calendar instance.
      • Methods inherited from class java.lang.Object

        equals, hashCode, toString
    • 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 the set_time_info array when calling the setTime 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 a Calendar 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 the TimeZone to be used along with this instance. This parameter must be set for CLOCK_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 this Calendar instance.
        Parameters:
        zone - the new Time zone to be used with this Calendar
        Throws:
        IllegalParameterException - when this method is used on an instance based on calendar type CLOCK_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 this Calendar 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 the getTime 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 is SET_TIME_INFO_LENGTH bytes. The applet does not need to know the internal structure of this data.
        offset - the offset in the set_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 this Calendar instance. If a TimeZone instance was configured for this Calendar instance, the time zone offset is added to the time base of this Calendar 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 the setTime 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 this Calendar instance, the time zone offset will be added to the time base. If this method is used on an instance based on the calendar type CLOCK_SOURCE_PRTC without first calling the setTime method, the behavior is not defined and an exception of type MeException might be thrown.
        Throws:
        IllegalParameterException - when set_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 the setTime method again might resolve the problem.
        UtilException - in case of an internal error.