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 booleanafter(ASDate otherDate)Tests if this date is after the specified date.java.lang.StringasString()Generates a String for output to the serialized PDF.booleanbefore(ASDate otherDate)Tests if this date is before the specified date.intcompareTo(ASDate otherASDate)Compares two Dates for ordering.intcompareTo(java.lang.Object obj)Compares two Dates for ordering.booleanequals(java.lang.Object obj)java.util.TimeZonegetTimeZone()Return theTimeZonerepresented by this ASDate if the internal representation is valid.inthashCode()booleanhasTimeZone()Returns if timezone is set explicitly set for this datebooleanisDateValid()If theASDateobject was instantiated with a string then it may be invalid and not represent a correct date as per the PDF spec.java.util.DatetoDate()Return theDaterepresented by this ASDate if the internal representation is valid.java.lang.StringtoString()Generates a String for debugging, messages, etc.java.lang.StringtoStringTimezoneUnaware()voidwrite(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 PDFParseExceptionCreate 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 theASDateobject 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:
trueif the date is valid;falseotherwise
-
compareTo
public int compareTo(java.lang.Object obj)
Compares two Dates for ordering.- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
obj- theASDateto be compared.- Returns:
- the value
0if the argument ASDate is equal to this ASDate; a value less than0if this ASDate is before the ASDate argument; and a value greater than0if this ASDate is after the ASDate argument.
-
compareTo
public int compareTo(ASDate otherASDate)
Compares two Dates for ordering.- Parameters:
otherASDate- theASDateto be compared.- Returns:
- the value
0if the argument ASDate is equal to this ASDate; a value less than0if this ASDate is before the ASDate argument; and a value greater than0if 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:
trueif and only if the instant represented by thisASDateis strictly earlier than the instant represented byotherDate;falseotherwise
-
after
public boolean after(ASDate otherDate)
Tests if this date is after the specified date.- Parameters:
otherDate- an ASDate- Returns:
trueif and only if the instant represented by thisASDateis strictly later than the instant represented byotherDate;falseotherwise
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein 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:
toStringin classjava.lang.Object
-
toStringTimezoneUnaware
public java.lang.String toStringTimezoneUnaware()
-
toDate
public java.util.Date toDate()
Return theDaterepresented 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 theTimeZonerepresented 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:
writein classASObject- Parameters:
outputByteStream- OutputByteStream to write to.- Throws:
PDFIOException- See Also:
ASString
-
-