|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--iaik.asn1.structures.ChoiceOfTime
This class represents the ASN.1 structure "ChoiceOfTime".
ChoiceOfTime ::= CHOICE { utcTime UTCTime, generalTime GeneralizedTime }
This class handles both possible rules to encode a date. The encoding format depends on the following rules:
Till year 2005 the date shall be encoded as UTCTime. After 2005 the date shall be encoded as GeneralizedTime.
Per default the encoding scheme of this class is set to UTCTime meaning that
per default the date value of a ChoiceOfTime object will be encoded as UTCTime.
However, an application may call the setEncodingType
method for enforcing a GeneralizedTime encoding, e.g.:
ChoiceOfTime choiceOfTime = new ChoiceOfTime(); choiceOfTime.setEncodingType(ASN.GeneralizedTime);This class supplies three constructors for specifying the Date to be represented by a ChoiceOfTime object:
constructor creates a ChoiceOfTime object
for the current date:
ChoiceOfTime choiceOfTime = new ChoiceOfTime();
constructor that expects the Date specification as
java.util.Date instance, e.g.:
Date date = ...;
ChoiceOfTime choiceOfTime = new ChoiceOfTime(date);
constructor where the Date may be supplied as string
representation of format "yyyyMMDDHHmmss" (year MonthOfYear DayOfMonth HourOfDay
minuteOfHour secondOfMinute) and an optional local time-shift against Coordinated
Universal Time (UTC time), which may be indicated by a plus (+) or minus (-) sign,
followed by hour and minute specifications, each of them owning two digits, e.g:
String timeStr = "19991003121730+0230";
ChoiceOfTime choiceOfTime = new ChoiceOfTime("19991003121730+0230",ASN.GeneralizedTime);
The second argument above enforces that the Date has to be encoded as GeneralizedTime
instead of UTCTime.
UTCTime,
GeneralizedTime| Constructor Summary | |
ChoiceOfTime()
Creates a new ChoiceOfTime from the current Date. |
|
ChoiceOfTime(ASN1Object obj)
Creates a new ChoiceOfTime from an ASN1Object. |
|
ChoiceOfTime(java.util.Date date)
Creates a new ChoiceOfTime from the given Date. |
|
ChoiceOfTime(java.lang.String date,
ASN encodingType)
Creates a ChoiceOfTime for the given date, represented as string. |
|
| Method Summary | |
java.util.Date |
getDate()
Returns the date this ChoiceOfTime represents. |
ASN |
getEncodingType()
Returns the encoding type, either UTCTime or GeneralizedTime. |
void |
setEncodingType(ASN encodingType)
Sets the encoding type. |
ASN1Object |
toASN1Object()
Returns the value of this object as an ASN1Object. |
java.lang.String |
toString()
Returns a string that represents the contents of the extensions. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Constructor Detail |
public ChoiceOfTime()
Per default the encoding scheme is set to UTCTime.
Use the setEncodingType
method for enforcing a GeneralizedTime encoding.
public ChoiceOfTime(java.util.Date date)
Per default the encoding scheme is set to UTCTime.
Use the setEncodingType
method for enforcing a GeneralizedTime encoding.
date - the desired date
public ChoiceOfTime(ASN1Object obj)
throws CodingException
toASN1Object()
method.obj - the ChoiceOfTime as ASN1Object
public ChoiceOfTime(java.lang.String date,
ASN encodingType)
throws java.text.ParseException
String timeStr = "19991003121730+0230";
ChoiceOfTime choiceOfTime = new ChoiceOfTime("19991003121730+0230",ASN.GeneralizedTime);
The second argument above enforces that the Date has to be encoded as GeneralizedTime
instead of UTCTime.date - the string containing the dateencodingType - the encoding type, either UTCTime or GeneralizedTime| Method Detail |
public ASN1Object toASN1Object()
public ASN getEncodingType()
public void setEncodingType(ASN encodingType)
throws java.lang.IllegalArgumentException
encodingType - the encoding typepublic java.util.Date getDate()
public java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||