Top Description Fields Constructors Methods
org.bouncycastle.asn1.cms

public Class Time

extends ASN1Object
implements ASN1Choice
Class Inheritance
All Implemented Interfaces
org.bouncycastle.asn1.ASN1Choice
Imports
java.text.ParseException, .SimpleDateFormat, java.util.Date, .Locale, .SimpleTimeZone, org.bouncycastle.asn1.ASN1Choice, .ASN1GeneralizedTime, .ASN1Object, .ASN1Primitive, .ASN1TaggedObject, .ASN1UTCTime, .DERGeneralizedTime, .DERUTCTime

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.

Field Summary

Modifier and TypeField and Description
pack-priv ASN1Primitive

Constructor Summary

AccessConstructor and Description
private
public
Time(Date
a date object representing the time of interest.
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.

public
Time(Date
a date object representing the time of interest.
time
,
Locale
an appropriate Locale for producing an ASN.1 GeneralizedTime value.
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.

Method Summary

Modifier and TypeMethod and Description
public Date
getDate()

Get java.util.Date version of date+time.

public static Time
getInstance(ASN1TaggedObject obj, boolean explicit)

public static Time
getInstance(Object
the object we want converted.
obj
)

Return a Time object from the given object.

public String
getTime()

Get the date+tine as a String in full form century format.

public ASN1Primitive
toASN1Primitive()

Implements abstract org.bouncycastle.asn1.ASN1Object.toASN1Primitive.

Implements org.bouncycastle.asn1.ASN1Encodable.toASN1Primitive.

Produce an object suitable for an ASN1OutputStream.
Inherited from org.bouncycastle.asn1.ASN1Object:
equalsgetEncodedgetEncodedhasEncodedTagValuehashCode

Field Detail

timeback to summary
pack-priv ASN1Primitive time

Constructor Detail

Timeback to summary
private Time(ASN1Primitive time)
Timeback to summary
public Time(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:Date

a date object representing the time of interest.

Timeback to summary
public Time(Date time, 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:Date

a date object representing the time of interest.

locale:Locale

an appropriate Locale for producing an ASN.1 GeneralizedTime value.

Method Detail

getDateback to summary
public Date getDate()

Get java.util.Date version of date+time.

getInstanceback to summary
public static Time getInstance(ASN1TaggedObject obj, boolean explicit)
getInstanceback to summary
public static Time getInstance(Object obj)

Return a Time object from the given object.

Accepted inputs:

Parameters
obj:Object

the object we want converted.

Exceptions
IllegalArgumentException:
if the object cannot be converted.
getTimeback to summary
public String getTime()

Get the date+tine as a String in full form century format.

toASN1Primitiveback to summary
public ASN1Primitive toASN1Primitive()

Implements abstract org.bouncycastle.asn1.ASN1Object.toASN1Primitive.

Implements org.bouncycastle.asn1.ASN1Encodable.toASN1Primitive.

Produce an object suitable for an ASN1OutputStream.

Returns:ASN1Primitive

Doc from org.bouncycastle.asn1.ASN1Object.toASN1Primitive.

a primitive representation of this object.