Package com.oss.asn1
Class AbstractISO8601Time
java.lang.Object
com.oss.asn1.AbstractData
com.oss.asn1.AbstractISO8601Time
- All Implemented Interfaces:
com.oss.asn1.Comparable
,ISO8601TimeInterface
,Serializable
,Cloneable
- Direct Known Subclasses:
ISO8601Date
,ISO8601DateTime
,ISO8601Duration
,ISO8601TimeOfDay
public abstract class AbstractISO8601Time
extends AbstractData
implements ISO8601TimeInterface, com.oss.asn1.Comparable
The ISO8601Time class implements the functionality common to all
ASN.1 useful time types: DATE, TIME-OF-DAY, DATE-TIME and DURATION.
This abstract base class is a public class, but it is not considered as being part of the public API and should not be directly referenced in your application programs.
- Since:
- ASN.1/Java 6.0
- See Also:
-
Field Summary
Fields inherited from class com.oss.asn1.AbstractData
EQUALS, GREATER_THAN, LESS_THAN
Fields inherited from interface com.oss.asn1.ISO8601TimeInterface
CENTURY, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_YEAR, FRACTIONAL_DIGITS, FRACTIONAL_VALUE, HOUR, MINUTE, MINUTE_DIFFERENTIAL, MONTH, SECOND, UNDEFINED, UTC, WEEK, YEAR, YEAR_DIGITS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
Create a deep copy of 'this' object.int
compareTo
(AbstractISO8601Time that) Compare 'this' object to another AbstractISO8601Time object to determine whether the contents of this object is less than, equal to, or greater than the contents of other object.int
compareTo
(AbstractISO8601Time that, TimeZone zone, Locale locale) Compare 'this' object to another AbstractISO8601Time object to determine whether the contents of this object is less than, equal to, or greater than the contents of other object.abstract ISO8601TimeInterface
Takes formatted string that contains the value of AbstractISO8601Time, splits the string to the components and initializes the instance of theAbstractISO8601Time
class, passed as a parameter.abstract void
Set an instance of this class from a String containing value notation of the TIME.final Date
toDate()
Get a Java Date object primed with the data from 'this' AbstractISO8601Time object.Get a Java Date object primed with the data from 'this' AbstractISO8601Time object using the calendar "calendar".abstract String
toFormattedString
(boolean isBer) Converts the instance ofISO8601TimeInterface
to the formatted string, suitable for the encoding.final boolean
validateTime
(int tag) Does basic sanity checks for the value of useful time types.Methods inherited from class com.oss.asn1.AbstractData
abstractEqualTo, delete, equals, getTypeName, hashCode, isEncodable, isPDU, isValid, toString, toString
Methods inherited from interface com.oss.asn1.ISO8601TimeInterface
clear, get, getTimeSettings, set
-
Constructor Details
-
AbstractISO8601Time
public AbstractISO8601Time()The default constructor.
-
-
Method Details
-
setValue
Set an instance of this class from a String containing value notation of the TIME.- Parameters:
value
- a string containing time value.- Throws:
BadTimeFormatException
- ifvalue
has invalid format
-
toDate
Get a Java Date object primed with the data from 'this' AbstractISO8601Time object.- Returns:
- reference to the Java Date object set to 'this' object's year, month, day, hour, minute and second.
-
toDate
Get a Java Date object primed with the data from 'this' AbstractISO8601Time object using the calendar "calendar".- 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".
-
compareTo
Compare 'this' object to another AbstractISO8601Time object to determine whether the contents of this object is less than, equal to, or greater than the contents of other object. The contents of Java Date objects primed with the data from 'this' object and another object are compared.- Parameters:
that
- the AbstractISO8601Time object to compare this object to.- Returns:
- LESS_THAN (-1) if the date specified by 'this' before the date specified by "that". EQUALS (0) if the date specified by 'this' is the same as the date specified by "that". GREATER_THAN (1) if the date specified by 'this' after the date specified by "that".
-
compareTo
Compare 'this' object to another AbstractISO8601Time object to determine whether the contents of this object is less than, equal to, or greater than the contents of other object. The contents of Java Date objects primed with the data from 'this' object and another object are compared.- Parameters:
that
- the AbstractISO8601Time object to compare this object to.zone
- specifies the time zone.locale
- specifies the locale.- Returns:
- LESS_THAN (-1) if the date specified by 'this' before the date specified by "that". EQUALS (0) if the date specified by 'this' is the same as the date specified by "that". GREATER_THAN (1) if the date specified by 'this' after the date specified by "that".
-
toFormattedString
Converts the instance ofISO8601TimeInterface
to the formatted string, suitable for the encoding.- Parameters:
isBer
- set to true if the time value is to be BER format- Returns:
- string that contain the value, formatted accordingly to the ISO8601 format
- Throws:
com.oss.util.BadTimeValueException
- if the the value contains invalid components that make the formatting impossible
-
parseTime
public abstract ISO8601TimeInterface parseTime(String str, boolean isBer) throws BadTimeFormatException Takes formatted string that contains the value of AbstractISO8601Time, splits the string to the components and initializes the instance of theAbstractISO8601Time
class, passed as a parameter. If the string has invalid format, a BadTimeFormatException exception is thrown. The method expects that the string has the format, specified in the description of thetoFormattedString
method.- Parameters:
str
- formatted string that contains the value of UTCTimeisBer
- indicates that the value is in special format, required by BER.- Returns:
- reference to initialized object
- Throws:
BadTimeFormatException
- ifstr
has invalid format
-
validateTime
public final boolean validateTime(int tag) throws com.oss.util.BadTimeValueException Does basic sanity checks for the value of useful time types. This version of the method checks if:- the
year
is later than1582
- the
month
is in range1..12
- the
day
is in range1..31
- the
hour
is in range0..24
- the
minute
is in range0..59
- the
second
is in range0..60
BadTimeValueException
exception is thrown.- Parameters:
tag
- ASN.1 UNIVERSAL tag that identifies the subtype of TIME type.- Returns:
true
if value passed validation check- Throws:
com.oss.util.BadTimeValueException
- if any component has an illegal value.
- the
-
clone
Create a deep copy of 'this' object.- Returns:
- copy of 'this' object.
-