Class ASDate
- java.lang.Object
-
- com.adobe.internal.pdftoolkit.core.types.ASObject
-
- com.adobe.internal.pdftoolkit.core.types.ASDate
-
- All Implemented Interfaces:
java.lang.Comparable
public class ASDate extends ASObject implements java.lang.Comparable
Represents a date which is a specific point in time. It provides for input and output of that date in ASN.1 format that is used by PDF.
-
-
Constructor Summary
Constructors Constructor Description ASDate()
Create an ASDate that references this moment in time.ASDate(ASString dateString)
Create an ASDate that point to the moment in time given by the String representation using the format given in the PDF 1.6 spec on page 133.ASDate(java.lang.String dateString)
Create an ASDate that point to the moment in time given by the String representation using the format given in the PDF 1.6 spec on page 133.ASDate(java.lang.String dateString, java.util.TimeZone zone)
ASDate(java.util.Date date)
Create an ASDate that points to the moment in time given by theDate
.ASDate(java.util.Date date, java.util.TimeZone zone)
Create an ASDate that points to the moment in time given by theDate
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
after(ASDate otherDate)
Tests if this date is after the specified date.java.lang.String
asString()
Generates a String for output to the serialized PDF.boolean
before(ASDate otherDate)
Tests if this date is before the specified date.int
compareTo(ASDate otherASDate)
Compares two Dates for ordering.int
compareTo(java.lang.Object obj)
Compares two Dates for ordering.boolean
equals(java.lang.Object obj)
java.util.TimeZone
getTimeZone()
Return theTimeZone
represented by this ASDate if the internal representation is valid.int
hashCode()
boolean
hasTimeZone()
Returns if timezone is set explicitly set for this dateboolean
isDateValid()
If theASDate
object was instantiated with a string then it may be invalid and not represent a correct date as per the PDF spec.java.util.Date
toDate()
Return theDate
represented by this ASDate if the internal representation is valid.java.lang.String
toString()
Generates a String for debugging, messages, etc.java.lang.String
toStringTimezoneUnaware()
void
write(OutputByteStream outputByteStream)
Writes the ADate to the given OutputByteStream in the format expected by the PDF Spec.
-
-
-
Constructor Detail
-
ASDate
public ASDate()
Create an ASDate that references this moment in time.
-
ASDate
public ASDate(java.util.Date date)
Create an ASDate that points to the moment in time given by theDate
.
-
ASDate
public ASDate(java.util.Date date, java.util.TimeZone zone)
Create an ASDate that points to the moment in time given by theDate
.
-
ASDate
public ASDate(java.lang.String dateString) throws PDFParseException
Create an ASDate that point to the moment in time given by the String representation using the format given in the PDF 1.6 spec on page 133.- Throws:
PDFParseException
-
ASDate
public ASDate(ASString dateString) throws PDFParseException
Create an ASDate that point to the moment in time given by the String representation using the format given in the PDF 1.6 spec on page 133.- Throws:
PDFParseException
-
ASDate
public ASDate(java.lang.String dateString, java.util.TimeZone zone) throws PDFParseException
- Throws:
PDFParseException
-
-
Method Detail
-
isDateValid
public boolean isDateValid()
If theASDate
object was instantiated with a string then it may be invalid and not represent a correct date as per the PDF spec. If the date is not valid then there is no way to convert the internal representation to a real date or timezone.- Returns:
true
if the date is valid;false
otherwise
-
compareTo
public int compareTo(java.lang.Object obj)
Compares two Dates for ordering.- Specified by:
compareTo
in interfacejava.lang.Comparable
- Parameters:
obj
- theASDate
to be compared.- Returns:
- the value
0
if the argument ASDate is equal to this ASDate; a value less than0
if this ASDate is before the ASDate argument; and a value greater than0
if this ASDate is after the ASDate argument.
-
compareTo
public int compareTo(ASDate otherASDate)
Compares two Dates for ordering.- Parameters:
otherASDate
- theASDate
to be compared.- Returns:
- the value
0
if the argument ASDate is equal to this ASDate; a value less than0
if this ASDate is before the ASDate argument; and a value greater than0
if this ASDate is after the ASDate argument. Invalid dates are considered to be before other dates.
-
before
public boolean before(ASDate otherDate)
Tests if this date is before the specified date.- Parameters:
otherDate
- an ASDate- Returns:
true
if and only if the instant represented by thisASDate
is strictly earlier than the instant represented byotherDate
;false
otherwise
-
after
public boolean after(ASDate otherDate)
Tests if this date is after the specified date.- Parameters:
otherDate
- an ASDate- Returns:
true
if and only if the instant represented by thisASDate
is strictly later than the instant represented byotherDate
;false
otherwise
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
asString
public java.lang.String asString()
Generates a String for output to the serialized PDF.
-
toString
public java.lang.String toString()
Generates a String for debugging, messages, etc.- Overrides:
toString
in classjava.lang.Object
-
toStringTimezoneUnaware
public java.lang.String toStringTimezoneUnaware()
-
toDate
public java.util.Date toDate()
Return theDate
represented by this ASDate if the internal representation is valid.- Returns:
- the date of the this object
-
hasTimeZone
public boolean hasTimeZone()
Returns if timezone is set explicitly set for this date- Returns:
- the timezone of this object
-
getTimeZone
public java.util.TimeZone getTimeZone()
Return theTimeZone
represented by this ASDate if the internal representation is valid.- Returns:
- the timezone of this object
-
write
public void write(OutputByteStream outputByteStream) throws PDFIOException
Writes the ADate to the given OutputByteStream in the format expected by the PDF Spec.- Specified by:
write
in classASObject
- Parameters:
outputByteStream
- OutputByteStream to write to.- Throws:
PDFIOException
- See Also:
ASString
-
-