Package com.oss.asn1
Class ISO8601DateTime
java.lang.Object
com.oss.asn1.AbstractData
com.oss.asn1.AbstractISO8601Time
com.oss.asn1.ISO8601DateTime
- All Implemented Interfaces:
com.oss.asn1.Comparable
,ISO8601TimeInterface
,Serializable
,Cloneable
The ISO8601DateTime class represents the ASN.1 DATE-TIME type
- 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
ConstructorsConstructorDescriptionThe default constructor.ISO8601DateTime
(int year, int month, int day, int hour, int minute, int second) Constructs time of day value hour, minute and second components.ISO8601DateTime
(String value) Constructs time of day value from a string. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears all the fields so they are set to UNDEFINED value.clone()
Clone 'this' object.final boolean
equalTo
(ISO8601DateTime that) Compare 'this' object to another ISO8601DateTime object to see if their contents are the same.int
get
(int field) Get field value.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
getMonth()
Get the month component of 'this' object.final int
Get the seconds component of 'this' object.Returns the name of ASN.1 type this java class represents.final int
getYear()
Get the year component of 'this' object.int
hashCode()
Returns a hash code for this objectTakes formatted string that contains the value of ISO8601DateTime, splits the string to the components and initializes this instance of theISO8601DateTime
class.void
set
(int field, int value) Set field value.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.final void
setMonth
(int month) Set the month component of 'this' object.final void
setSecond
(int second) Set the seconds component of 'this' object.void
Set an instance of this class from a String containing value notation of the DATE-TIME.final void
setYear
(int year) Set the year component of 'this' object.final String
toFormattedString
(boolean isBer) Converts this instance ofISO8601TimeInterface
to the formatted string, suitable for the encoding.Methods inherited from class com.oss.asn1.AbstractISO8601Time
compareTo, compareTo, toDate, toDate, validateTime
Methods inherited from class com.oss.asn1.AbstractData
delete, equals, isEncodable, isPDU, isValid, toString, toString
-
Constructor Details
-
ISO8601DateTime
public ISO8601DateTime()The default constructor. -
ISO8601DateTime
Constructs time of day value from a string. String should be in the "YYYY-MM-DDTHH:MM:SS" format, whereYYYY
is a four-digit year,MM
is a two-digit month,DD
is a two-digit day number,HH
is a two-digit hour,MM
is a two-digit minute andSS
is a two-digit second.- Parameters:
value
- a string containing time of day value.- Throws:
BadTimeFormatException
- ifvalue
has invalid format.
-
ISO8601DateTime
public ISO8601DateTime(int year, int month, int day, int hour, int minute, int second) Constructs time of day value hour, minute and second components.- Parameters:
year
- year valuemonth
- month valueday
- day valuehour
- hour valueminute
- minute valuesecond
- second value
-
-
Method Details
-
clone
Clone 'this' object.- Returns:
- deep copy of 'this' object.
-
setValue
Set an instance of this class from a String containing value notation of the DATE-TIME.- Specified by:
setValue
in classAbstractISO8601Time
- Parameters:
value
- a string containing time value.- Throws:
BadTimeFormatException
- ifvalue
has invalid format
-
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.
-
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.
-
get
public int get(int field) Get field value.- Parameters:
field
- field designator.- Returns:
- field value.
-
set
public void set(int field, int value) Set field value.- Parameters:
field
- field designator.value
- field value.
-
clear
public void clear()Clears all the fields so they are set to UNDEFINED value. -
equalTo
Compare 'this' object to another ISO8601DateTime object to see if their contents are the same.- Parameters:
that
- the ISO8601DateTime object to compare 'this' object to.- Returns:
- true if contents of both objects are the same.
-
toFormattedString
Converts this instance ofISO8601TimeInterface
to the formatted string, suitable for the encoding. The string returned has the following format:YYYYMMDDHHMMSS
orYYYY-MM-DDTHH:MM:SS
YYYY
is a four-digit year, andMM
,DD
,HH
,MM
andSS
mean month, day, hour, minute and second correspondingly. First form used to represent BER format. Second form means that the time is a value notation.- Specified by:
toFormattedString
in classAbstractISO8601Time
- Parameters:
isBer
- set to true if the time value is to be BER format- Returns:
- string that contain the value, formatted accordingly to the ISO8601DateTime format
- 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 ISO8601DateTime, splits the string to the components and initializes this instance of theISO8601DateTime
class. 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.- Specified by:
parseTime
in classAbstractISO8601Time
- Parameters:
str
- formatted string that contains the value of ISO8601DateTimeisBer
- set to true if the time value is to be BER format- Returns:
- reference to this 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
-
getTypeName
Returns the name of ASN.1 type this java class represents.- Overrides:
getTypeName
in classAbstractData
- Returns:
- the name of the ASN.1 type.
-