Package com.oss.asn1
Class GeneralizedTime
java.lang.Object
com.oss.asn1.AbstractData
com.oss.asn1.AbstractTime
com.oss.asn1.GeneralizedTime
- All Implemented Interfaces:
Serializable
,Cloneable
The GeneralizedTime class represents the ASN.1 GeneralizedTime type.
- Since:
- ASN.1/Java 1.0-beta A
- See Also:
-
Field Summary
Fields inherited from class com.oss.asn1.AbstractData
EQUALS, GREATER_THAN, LESS_THAN
-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor.GeneralizedTime
(int[] components, boolean isUTCTime) Construct an instance of this class from an int array.GeneralizedTime
(int year, int month, int day, int hour, int minute, int second, int minDiff, int millisecond, boolean isUTCTime) Construct from individual time components.GeneralizedTime
(String value) Construct an instance of this class from a String containing value notation of the GeneralizedTime. -
Method Summary
Modifier and TypeMethodDescriptionfinal int
compareTo
(GeneralizedTime that) Compare 'this' object to another GeneralizedTime object to determine whether the contents of this object is less than, equal to, or greater than the contents of other object.final int
compareTo
(GeneralizedTime that, TimeZone zone, Locale locale) Compare 'this' object to another object of the same class to determine whether the contents of this object is less than, equal to, or greater than the contents of other object.final boolean
equalTo
(GeneralizedTime that) Compare 'this' object to another GeneralizedTime object to see if their contents are the same.final boolean
Determine whether this GeneralizedTime represents a UTCTime value (with 'Z').final int
Get the millisecond component of 'this' object.final int[]
Get an int array containing the components of 'this' object.final void
setIsUTCTime
(boolean isUTCTime) Specify that this GeneralizedTime should represent UTCTime.final void
setMillisecond
(int millisecond) Set the millisecond component of 'this' object.final void
setMinuteDifferential
(int minDiff) Set the minute-differential component of 'this' object if the isUTCTime flag is false.final void
setValue
(int[] components, boolean isUTCTime) Set the value of a GeneralizedTime from an array of int that contains the year, month, day, hour, minute, second, minute-differential and millisecond.void
Set an instance of this class from a String containing value notation of the GeneralizedTime.final Date
Get a Java Date object primed with the data from 'this' AbstractTime object using the calendar "calendar".Methods inherited from class com.oss.asn1.AbstractTime
getDay, getHour, getMinute, getMinuteDifferential, getMonth, getSecond, getYear, hashCode, setDay, setHour, setMinute, setMonth, setSecond, setValue, setYear, toDate
Methods inherited from class com.oss.asn1.AbstractData
clone, delete, equals, isEncodable, isPDU, isValid, toString, toString
-
Constructor Details
-
GeneralizedTime
public GeneralizedTime()The default constructor. -
GeneralizedTime
public GeneralizedTime(int year, int month, int day, int hour, int minute, int second, int minDiff, int millisecond, boolean isUTCTime) Construct from individual time components.- Parameters:
year
- the year to set.month
- the month to set.day
- the day to set.hour
- the hour to set.minute
- the minute to sey.second
- the second to set.minDiff
- the minute-differential to set.millisecond
- the millisecond to set.isUTCTime
- true if 'Z' is included.
-
GeneralizedTime
public GeneralizedTime(int[] components, boolean isUTCTime) Construct an instance of this class from an int array. The int array contains the time components in the order: year, month, day, hour, minute, second, minute-differential and millisecond.- Parameters:
components
- the int array of time components.isUTCTime
- true if 'Z' is included.
-
GeneralizedTime
Construct an instance of this class from a String containing value notation of the GeneralizedTime.- Parameters:
value
- string containing GeneralizedTime value.- Throws:
BadTimeFormatException
- ifvalue
has invalid format- See Also:
-
-
Method Details
-
getMillisecond
public final int getMillisecond()Get the millisecond component of 'this' object.- Returns:
- an int indicating the millisecond.
-
setMillisecond
public final void setMillisecond(int millisecond) Set the millisecond component of 'this' object.- Parameters:
millisecond
- the millisecond to set.
-
getIsUTCTime
public final boolean getIsUTCTime()Determine whether this GeneralizedTime represents a UTCTime value (with 'Z').- Returns:
- boolean indicating the status as UTCTime.
-
setIsUTCTime
public final void setIsUTCTime(boolean isUTCTime) Specify that this GeneralizedTime should represent UTCTime.- Parameters:
isUTCTime
- true if UTCTime, false if GeneralizedTime.
-
setMinuteDifferential
public final void setMinuteDifferential(int minDiff) Set the minute-differential component of 'this' object if the isUTCTime flag is false. Otherwise, do nothing.- Overrides:
setMinuteDifferential
in classAbstractTime
- Parameters:
minDiff
- the minute-differential to set.
-
intArrayValue
public final int[] intArrayValue()Get an int array containing the components of 'this' object. The components are in the order: year, month, day, hour, minute, second, minute-differential, millisecond.- Overrides:
intArrayValue
in classAbstractTime
- Returns:
- int array of time components.
-
setValue
public final void setValue(int[] components, boolean isUTCTime) Set the value of a GeneralizedTime from an array of int that contains the year, month, day, hour, minute, second, minute-differential and millisecond.- Parameters:
components
- an array of time components.isUTCTime
- a boolean specified whether this GeneralizedTime represents UTCTime with 'Z'.
-
setValue
Set an instance of this class from a String containing value notation of the GeneralizedTime. The value notation has the following format:YYYYMMDDHHMMSS[.FFF]+hhmm
orYYYYMMDDHHMMSS[.FFF]-hhmm
orYYYYMMDDHHMMSS[.FFF]
orYYYYMMDDHHMMSS[.FFF]Z
YYYY
is a four-digit year, andMM
,DD
,HH
,MM
,SS
andFFF
mean month, day, hour, minute, second and fractions of second (millisecond) correspondingly. If millisecond equal to zero, the fractional part (including the decimal point) is omitted. First two forms used to represent values with non-zero minute differential. Third form means that the time is a local time and the fourth form used to represent UTC time.- Parameters:
value
- string containing GeneralizedTime value.- Throws:
BadTimeFormatException
- ifvalue
has invalid format
-
toDate
Get a Java Date object primed with the data from 'this' AbstractTime object using the calendar "calendar". Note that the precision is milliseconds.- Overrides:
toDate
in classAbstractTime
- Parameters:
calendar
- the Calendar to use to compute the Date.- Returns:
- reference to the Java Date set to 'this' object's year, month, day, hour, minute and second by using "calendar".
-
equalTo
Compare 'this' object to another GeneralizedTime object to see if their contents are the same.- Parameters:
that
- the GeneralizedTime object to compare 'this' object to.- Returns:
- true if contents of both objects are the same.
-
compareTo
Compare 'this' object to another GeneralizedTime object to determine whether the contents of this object is less than, equal to, or greater than the contents of other object.- Parameters:
that
- the GeneralizedTime object to compare 'this' object to.- Returns:
- LESS_THAN, EQUALS, GREATER_THAN values as the results of comparison.
- Throws:
NullPointerException
- thrown when 'that' is null.
-
compareTo
Compare 'this' object to another object of the same class to determine whether the contents of this object is less than, equal to, or greater than the contents of other object.- Parameters:
that
- the GeneralizedTime object to compare 'this' object to.zone
- the TimeZone object to use during comparison.locale
- the Locale object to use during comparison.- Returns:
- LESS_THAN, EQUALS, GREATER_THAN values as the results of comparison.
- Throws:
NullPointerException
- thrown when 'that' is null.
-