Package com.oss.asn1
Class AbstractTime
java.lang.Object
com.oss.asn1.AbstractData
com.oss.asn1.AbstractTime
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
GeneralizedTime
,UTCTime
The AbstractTime class is the superclass of the two ASN.1 time types,
GeneralizedTime and UTCTime.
- Since:
- ASN.1/Java 6.0
- See Also:
-
Field Summary
Fields inherited from class com.oss.asn1.AbstractData
EQUALS, GREATER_THAN, LESS_THAN
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone 'this' object.abstract String
Takes the instance ofAbstractTime
and converts it to the formatted string, suitable for the encoding.final int
getDay()
Get the day component of 'this' object.final int
getHour()
Get the hour component of 'this' object.final int
Get the minutes component of 'this' object.final int
Get the minutes-differential component of 'this' object.final int
getMonth()
Get the month component of 'this' object.final int
Get the seconds component of 'this' object.final int
getYear()
Get the year component of 'this' object.int
hashCode()
Returns a hash code for this objectint[]
Get an int array containing the components of this object.abstract AbstractTime
Takes formatted string that contains the value of time type, splits the string to the components and initializes the instance of theAbstractTime
class, passed as a parameter.final void
setDay
(int day) Set the day component of 'this' object.final void
setHour
(int hour) Set the hour component of 'this' object.final void
setMinute
(int minute) Set the minutes component of 'this' object.void
setMinuteDifferential
(int minDiff) Set the minutes-differential component of 'this' object.final void
setMonth
(int month) Set the month component of 'this' object.final void
setSecond
(int second) Set the seconds component of 'this' object.final void
setValue
(int[] components) Set the value of an AbstractTime object from an array of int that contains the year, month, day, hour, minutes, seconds and minutes-differential.final void
setYear
(int year) Set the year component of 'this' object.final Date
toDate()
Get a Java Date object primed with the data from 'this' AbstractTime object.Get a Java Date object primed with the data from 'this' AbstractTime object using the calendar "calendar".boolean
Does basic sanity checks for the value of time types.Methods inherited from class com.oss.asn1.AbstractData
abstractEqualTo, delete, equals, getTypeName, isEncodable, isPDU, isValid, toString, toString
-
Method Details
-
clone
Clone 'this' object.- Returns:
- deep copy of 'this' object.
-
getYear
public final int getYear()Get the year component of 'this' object.- Returns:
- int value indicating the year.
-
getMonth
public final int getMonth()Get the month component of 'this' object.- Returns:
- int value indicating the month.
-
getDay
public final int getDay()Get the day component of 'this' object.- Returns:
- int value indicating the day.
-
getHour
public final int getHour()Get the hour component of 'this' object.- Returns:
- int value indicating the hour.
-
getMinute
public final int getMinute()Get the minutes component of 'this' object.- Returns:
- int value indicating the minute.
-
getSecond
public final int getSecond()Get the seconds component of 'this' object.- Returns:
- int value indicating the second.
-
getMinuteDifferential
public final int getMinuteDifferential()Get the minutes-differential component of 'this' object.- Returns:
- int value indicating the minute-differential.
-
setYear
public final void setYear(int year) Set the year component of 'this' object.- Parameters:
year
- the year to set.
-
setMonth
public final void setMonth(int month) Set the month component of 'this' object.- Parameters:
month
- the month to set.
-
setDay
public final void setDay(int day) Set the day component of 'this' object.- Parameters:
day
- the day to set.
-
setHour
public final void setHour(int hour) Set the hour component of 'this' object.- Parameters:
hour
- the hour to set.
-
setMinute
public final void setMinute(int minute) Set the minutes component of 'this' object.- Parameters:
minute
- the minute to set.
-
setSecond
public final void setSecond(int second) Set the seconds component of 'this' object.- Parameters:
second
- the second to set.
-
setMinuteDifferential
public void setMinuteDifferential(int minDiff) Set the minutes-differential component of 'this' object.- Parameters:
minDiff
- the minute-differential to set.
-
setValue
public final void setValue(int[] components) Set the value of an AbstractTime object from an array of int that contains the year, month, day, hour, minutes, seconds and minutes-differential.- Parameters:
components
- an array of time components.
-
intArrayValue
public int[] intArrayValue()Get an int array containing the components of this object. The components are in the order: year, month, day, hour, minutes, seconds, minutes-differential.- Returns:
- int array of time components.
-
toDate
Get a Java Date object primed with the data from 'this' AbstractTime object. Note that the precision stops at seconds, milliseconds are lost.- Returns:
- reference to the Java Date object set to 'this' object's year, month, day, hour, minutes and seconds.
-
toDate
Get a Java Date object primed with the data from 'this' AbstractTime object using the calendar "calendar". Note that the precision stops at seconds, milliseconds are lost.- 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, minutes and seconds by using "calendar".
-
validateTime
public boolean validateTime() throws com.oss.util.BadTimeValueExceptionDoes basic sanity checks for the value of time types. Subclasses are supposed to override this method to implement more strict or additional checks. This version of the method checks if:- the
month
is in range1..12
- the
day
is in range1..31
- the
hour
is in range0..23
- the
minute
is in range0..59
- the
second
is in range0..59
BadTimeValueException
exception is thrown.- Returns:
- true if value passed validation check
- Throws:
com.oss.util.BadTimeValueException
- if any component has an illegal value.
- the
-
formatTime
Takes the instance ofAbstractTime
and converts it to the formatted string, suitable for the encoding. Specific subclasses must implement this method.- Returns:
- string that contain the value, formatted accordingly to the specific time type
- Throws:
com.oss.util.BadTimeValueException
- if the the value contains invalid components that make the formatting impossible
-
parseTime
Takes formatted string that contains the value of time type, splits the string to the components and initializes the instance of theAbstractTime
class, passed as a parameter. If the string has invalid format, a BadTimeFormatException exception is thrown. Specific subclasses must implement this method.- Parameters:
str
- formatted string that contains the value of time type- Returns:
- reference to initialized object
- Throws:
BadTimeFormatException
- ifstr
has invalid format
-
hashCode
public int hashCode()Returns a hash code for this object- Overrides:
hashCode
in classAbstractData
- Returns:
- a hash code for this object
-