Class Time

  • All Implemented Interfaces:
    ASN1Choice, ASN1Encodable, Encodable

    public class Time
    extends ASN1Object
    implements ASN1Choice
    RFC 5652: Dual-mode timestamp format producing either UTCTIme or GeneralizedTime.

     Time ::= CHOICE {
         utcTime        UTCTime,
         generalTime    GeneralizedTime }
     

    This has a constructor using java.util.Date for input which generates a DERUTCTime object if the supplied datetime is in range 1950-01-01-00:00:00 UTC until 2049-12-31-23:59:60 UTC. If the datetime value is outside that range, the generated object will be DERGeneralizedTime.

    • Constructor Summary

      Constructors 
      Constructor Description
      Time​(java.util.Date time)
      Creates a time object from a given date - if the date is between 1950 and 2049 a UTCTime object is generated, otherwise a GeneralizedTime is used.
      Time​(java.util.Date time, java.util.Locale locale)
      Creates a time object from a given date and locale - if the date is between 1950 and 2049 a UTCTime object is generated, otherwise a GeneralizedTime is used.
      Time​(ASN1Primitive time)
      Deprecated.
      use getInstance()
    • Constructor Detail

      • Time

        public Time​(ASN1Primitive time)
        Deprecated.
        use getInstance()
      • Time

        public Time​(java.util.Date time)
        Creates a time object from a given date - if the date is between 1950 and 2049 a UTCTime object is generated, otherwise a GeneralizedTime is used.
        Parameters:
        time - a date object representing the time of interest.
      • Time

        public Time​(java.util.Date time,
                    java.util.Locale locale)
        Creates a time object from a given date and locale - if the date is between 1950 and 2049 a UTCTime object is generated, otherwise a GeneralizedTime is used. You may need to use this constructor if the default locale doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations.
        Parameters:
        time - a date object representing the time of interest.
        locale - an appropriate Locale for producing an ASN.1 GeneralizedTime value.
    • Method Detail

      • getInstance

        public static Time getInstance​(java.lang.Object obj)
        Return a Time object from the given object.

        Accepted inputs:

        Parameters:
        obj - the object we want converted.
        Throws:
        java.lang.IllegalArgumentException - if the object cannot be converted.
      • getTime

        public java.lang.String getTime()
        Get the date+tine as a String in full form century format.
      • getDate

        public java.util.Date getDate()
        Get java.util.Date version of date+time.