Package org.bouncycastle.asn1.cms
Class Time
java.lang.Object
org.bouncycastle.asn1.ASN1Object
org.bouncycastle.asn1.cms.Time
- All Implemented Interfaces:
org.bouncycastle.asn1.ASN1Choice
,org.bouncycastle.asn1.ASN1Encodable
,org.bouncycastle.util.Encodable
public class Time
extends org.bouncycastle.asn1.ASN1Object
implements org.bouncycastle.asn1.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
ConstructorDescriptionCreates 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.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. -
Method Summary
Modifier and TypeMethodDescriptiongetDate()
Get java.util.Date version of date+time.static Time
getInstance
(Object obj) Return a Time object from the given object.static Time
getInstance
(org.bouncycastle.asn1.ASN1TaggedObject obj, boolean explicit) getTime()
Get the date and time as a String in full form century format.org.bouncycastle.asn1.ASN1Primitive
Produce an object suitable for an ASN1OutputStream.Methods inherited from class org.bouncycastle.asn1.ASN1Object
encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode
-
Constructor Details
-
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
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 Details
-
getInstance
-
getInstance
Return a Time object from the given object.Accepted inputs:
- null → null
-
Time
object -
DERUTCTime
object -
DERGeneralizedTime
object
- Parameters:
obj
- the object we want converted.- Throws:
IllegalArgumentException
- if the object cannot be converted.
-
getTime
Get the date and time as a String in full form century format. -
getDate
Get java.util.Date version of date+time. -
toASN1Primitive
public org.bouncycastle.asn1.ASN1Primitive toASN1Primitive()Produce an object suitable for an ASN1OutputStream.- Specified by:
toASN1Primitive
in interfaceorg.bouncycastle.asn1.ASN1Encodable
- Specified by:
toASN1Primitive
in classorg.bouncycastle.asn1.ASN1Object
-