Class 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 the Date.
      ASDate​(java.util.Date date, java.util.TimeZone zone)
      Create an ASDate that points to the moment in time given by the Date.
    • 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 the TimeZone represented by this ASDate if the internal representation is valid.
      int hashCode()  
      boolean hasTimeZone()
      Returns if timezone is set explicitly set for this date
      boolean isDateValid()
      If the ASDate 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 the Date 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.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • 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 the Date.
      • ASDate

        public ASDate​(java.util.Date date,
                      java.util.TimeZone zone)
        Create an ASDate that points to the moment in time given by the Date.
      • 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
    • Method Detail

      • isDateValid

        public boolean isDateValid()
        If the ASDate 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 interface java.lang.Comparable
        Parameters:
        obj - the ASDate to be compared.
        Returns:
        the value 0 if the argument ASDate is equal to this ASDate; a value less than 0 if this ASDate is before the ASDate argument; and a value greater than 0 if this ASDate is after the ASDate argument.
      • compareTo

        public int compareTo​(ASDate otherASDate)
        Compares two Dates for ordering.
        Parameters:
        otherASDate - the ASDate to be compared.
        Returns:
        the value 0 if the argument ASDate is equal to this ASDate; a value less than 0 if this ASDate is before the ASDate argument; and a value greater than 0 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 this ASDate is strictly earlier than the instant represented by otherDate; 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 this ASDate is strictly later than the instant represented by otherDate; false otherwise
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.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 class java.lang.Object
      • toStringTimezoneUnaware

        public java.lang.String toStringTimezoneUnaware()
      • toDate

        public java.util.Date toDate()
        Return the Date 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 the TimeZone represented by this ASDate if the internal representation is valid.
        Returns:
        the timezone of this object