public final class ASN1Time extends AbstractFieldsObject
The API offered by this class is as if the type were specified in ASN.1 as follows.
ASN1Time ::= SEQUENCE { isUTCTime BOOLEAN DEFAULT FALSE, year INTEGER DEFAULT 0, month INTEGER DEFAULT 0, day INTEGER DEFAULT 0, hour INTEGER DEFAULT 0, minute INTEGER DEFAULT 0, second INTEGER DEFAULT 0, minuteDifferential INTEGER DEFAULT 0, milliSecond INTEGER DEFAULT 0 }Default values are provided so that times of various precisions can be represented without needing to set values for irrelevant fields. Note that the isUTCTime field corresponds to the ASN.1 type being represented, not to whether the time is written textually in UTC - that's represented by minuteDifferential.
FIELD_ABSENT, FIELD_UNINITIALISED
Constructor and Description |
---|
ASN1Time()
Constructs a new ASN1Time object with no fields set.
|
Modifier and Type | Method and Description |
---|---|
void |
checkFieldsSet()
Checks that all mandatory fields are present.
|
ASN1Time |
clone()
Constructs a copy of this object and everything reachable from it.
|
static ASN1Time |
copyOf(ASN1Time from)
Creates a new object of this type, cloning the values of common fields from the given object of any subclass of the same base type.
|
boolean |
equals(Object o)
Compares some other Object to this one for equality by value (not reference).
|
static ASN1Time |
fromCalendar(Calendar calendar)
Converts the given Calendar to a new object of this type.
|
int |
getDay()
Gets the value of the field Day.
|
static FieldAccessor[] |
getFieldAccessors()
Gets a new array of the accessors for fields of this type.
|
Map<String,Object> |
getFieldsMap(boolean withAbsents)
Gets a Map from field-name to field-value for the fields of a sequence.
|
int |
getHour()
Gets the value of the field Hour.
|
boolean |
getIsUTCTime()
Gets whether the time is a UTC time.
|
int |
getMilliSecond()
Gets the value of the field MilliSecond.
|
int |
getMinute()
Gets the value of the field Minute.
|
int |
getMinuteDifferential()
Gets the value of the field MinuteDifferential.
|
int |
getMonth()
Gets the value of the field Month.
|
int |
getSecond()
Gets the value of the field Second.
|
int |
getYear()
Gets the value of the field Year.
|
boolean |
hasDay()
Tests whether the field Day has a value.
|
int |
hashCode()
Returns a hash code value for this object.
|
boolean |
hasHour()
Tests whether the field Hour has a value.
|
boolean |
hasIsUTCTime()
Tests whether the field IsUTCTime has a value.
|
boolean |
hasMilliSecond()
Tests whether the field MilliSecond has a value.
|
boolean |
hasMinute()
Tests whether the field Minute has a value.
|
boolean |
hasMinuteDifferential()
Tests whether the field MinuteDifferential has a value.
|
boolean |
hasMonth()
Tests whether the field Month has a value.
|
boolean |
hasSecond()
Tests whether the field Second has a value.
|
boolean |
hasYear()
Tests whether the field Year has a value.
|
int[] |
intArrayValue()
Gets this time as an array of year,month,day,hour,minute,second,[any minute differential,]millisecond.
|
ASN1Time |
setDay(int value)
Sets the value of the field Day.
|
ASN1Time |
setDayPresent(boolean flag)
Sets the presence or absence of the field Day.
|
ASN1Time |
setHour(int value)
Sets the value of the field Hour.
|
ASN1Time |
setHourPresent(boolean flag)
Sets the presence or absence of the field Hour.
|
ASN1Time |
setIsUTCTime(boolean value)
Sets whether the time is a UTC time.
|
ASN1Time |
setIsUTCTimePresent(boolean flag)
Sets the presence or absence of the field IsUTCTime.
|
ASN1Time |
setMilliSecond(int value)
Sets the value of the field millisecond.
|
ASN1Time |
setMilliSecondPresent(boolean flag)
Sets the presence or absence of the field MilliSecond.
|
ASN1Time |
setMinute(int value)
Sets the value of the field Minute.
|
ASN1Time |
setMinuteDifferential(int value)
Sets the value of the field Minute differential.
|
ASN1Time |
setMinuteDifferentialPresent(boolean flag)
Sets the presence or absence of the field MinuteDifferential.
|
ASN1Time |
setMinutePresent(boolean flag)
Sets the presence or absence of the field Minute.
|
ASN1Time |
setMonth(int value)
Sets the value of the field Month.
|
ASN1Time |
setMonthPresent(boolean flag)
Sets the presence or absence of the field Month.
|
ASN1Time |
setSecond(int value)
Sets the value of the field Second.
|
ASN1Time |
setSecondPresent(boolean flag)
Sets the presence or absence of the field Second.
|
ASN1Time |
setValue(int[] components)
Sets this time according to an array of year,month,day,hour,minute,second,[any minute differential,]millisecond.
|
ASN1Time |
setYear(int value)
Sets the value of the field Year.
|
ASN1Time |
setYearPresent(boolean flag)
Sets the presence or absence of the field Year.
|
Calendar |
toCalendar()
Gets this time as a Calendar instance
|
Date |
toDate()
Gets this time as a Date instance
|
String |
toString()
Stringize this AbstractFieldsObject to ASN.1 value notation.
|
checkModify, isReadOnly, setReadOnly
public boolean hasIsUTCTime()
public ASN1Time setIsUTCTimePresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasYear()
public ASN1Time setYearPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasMonth()
public ASN1Time setMonthPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasDay()
public ASN1Time setDayPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasHour()
public ASN1Time setHourPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasMinute()
public ASN1Time setMinutePresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasSecond()
public ASN1Time setSecondPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasMinuteDifferential()
public ASN1Time setMinuteDifferentialPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasMilliSecond()
public ASN1Time setMilliSecondPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic void checkFieldsSet() throws EncodeException
EncodeException
- if any mandatory field is not presentpublic boolean getIsUTCTime()
public int getYear()
public int getMonth()
public int getDay()
public int getHour()
public int getMinute()
public int getSecond()
public int getMinuteDifferential()
public int getMilliSecond()
public ASN1Time setIsUTCTime(boolean value)
value
- booleanpublic ASN1Time setYear(int value)
value
- int representation of the fieldpublic ASN1Time setMonth(int value)
value
- int representation of the fieldpublic ASN1Time setDay(int value)
value
- int representation of the fieldpublic ASN1Time setHour(int value)
value
- int representation of the fieldpublic ASN1Time setMinute(int value)
value
- int representation of the fieldpublic ASN1Time setSecond(int value)
value
- int representation of the fieldpublic ASN1Time setMinuteDifferential(int value)
value
- int representation of the fieldpublic ASN1Time setMilliSecond(int value)
value
- int representation of the fieldpublic static ASN1Time copyOf(ASN1Time from)
from
- the object from which to copypublic ASN1Time clone()
clone
in interface DataObject
clone
in class AbstractDataObject
public static FieldAccessor[] getFieldAccessors()
public Map<String,Object> getFieldsMap(boolean withAbsents)
getFieldsMap
in class AbstractFieldsObject
withAbsents
- whether to put absent optional fields into Mappublic int[] intArrayValue()
public ASN1Time setValue(int[] components)
components
- int arraypublic Calendar toCalendar()
public Date toDate()
public String toString()
AbstractFieldsObject
{ field1Name field1Value, field2Name field2Value, ...., fieldNName fieldNValue }If a CHOICE, then a labelled value:
label : value.
Field values are stringized in a form that depends on their type:
'C0FFEE'H
(ASN.1 OCTET STRING hstring syntax)
{ a, b, c, d }
(ASN.1 SEQUENCE OF syntax)
Absent optional fields are not included in the stringized form.
Uninitialised mandatory fields are shown as "-- UNINITIALISED --". This includes an uninitialised choice.
toString
in class AbstractFieldsObject
public int hashCode()
AbstractFieldsObject
hashCode
in class AbstractFieldsObject
public boolean equals(Object o)
AbstractFieldsObject
equals
in class AbstractFieldsObject