org.bouncycastle.asn1.x509

## Class Time

- java.lang.Object
- - org.bouncycastle.asn1.ASN1Object
  - - org.bouncycastle.asn1.x509.Time

- All Implemented Interfaces:
    ASN1Choice, ASN1Encodable, Encodable

      public class Time
      extends ASN1Object
      implements ASN1Choice

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Time(ASN1Primitive time)`
    `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.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.Date` | `getDate()`
    `static Time` | `getInstance(ASN1TaggedObject obj, boolean explicit)`
    `static Time` | `getInstance(java.lang.Object obj)`
    `java.lang.String` | `getTime()`
    `ASN1Primitive` | `toASN1Primitive()` Produce an object suitable for an ASN1OutputStream.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class org.bouncycastle.asn1.ASN1Object

      `encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Time

          public Time(ASN1Primitive time)

    - #### 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. The `locale` selects the calendar used by the underlying `SimpleDateFormat`. Most callers should prefer the simple `Time(Date)` form, which always formats under an English Gregorian locale (so the encoded year is the spec-mandated Gregorian one regardless of `Locale.getDefault()`, including on JVMs whose default uses a non-Gregorian calendar such as Thai Buddhist `th_TH_TH_#u-nu-thai` or Japanese Imperial `ja_JP_JP_#u-ca-japanese`). Reach for this `(Date, Locale)` form only when you need explicit control over the formatter's calendar.
      Parameters:
        `time` - a date object representing the time of interest.
        `locale` - the Locale whose calendar the underlying SimpleDateFormat should use.

  - ### Method Detail

    - #### getInstance

          public static Time getInstance(ASN1TaggedObject obj,
                                         boolean explicit)

    - #### getInstance

          public static Time getInstance(java.lang.Object obj)

    - #### getTime

          public java.lang.String getTime()

    - #### getDate

          public java.util.Date getDate()

    - #### toASN1Primitive

          public ASN1Primitive toASN1Primitive()

      Produce an object suitable for an ASN1OutputStream.

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

      Specified by:
        `toASN1Primitive` in interface `ASN1Encodable`
      Specified by:
        `toASN1Primitive` in class `ASN1Object`
      Returns:
        a primitive representation of this object.

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`