Package com.dd.plist

Class NSDate

    • Constructor Summary

      Constructors 
      Constructor Description
      NSDate​(byte[] bytes)
      Creates new NSDate instance from its binary representation.
      NSDate​(byte[] bytes, int startIndex, int endIndex)
      Creates a new NSDate instance from its binary representation.
      NSDate​(java.lang.String textRepresentation)
      Creates a new NSDate instance from is textual representation.
      NSDate​(java.util.Date d)
      Creates a new NSDate instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      NSDate clone()
      Creates and returns a deep copy of this instance.
      int compareTo​(NSObject o)  
      boolean equals​(java.lang.Object obj)  
      java.util.Date getDate()
      Gets the date.
      int hashCode()  
      private static java.lang.String makeDateString​(java.util.Date date)
      Generates a string representation of a Java Date object.
      private static java.lang.String makeDateStringGnuStep​(java.util.Date date)
      Generates a string representation of a Java Date object.
      private static java.util.Date parseDateString​(java.lang.String textRepresentation)
      Parses a date string and creates a Java Date object from it.
      protected void toASCII​(java.lang.StringBuilder ascii, int level)
      Generates the ASCII representation of this object.
      protected void toASCIIGnuStep​(java.lang.StringBuilder ascii, int level)
      Generates the ASCII representation of this object in the GnuStep format.
      (package private) void toBinary​(BinaryPropertyListWriter out)
      Generates the binary representation of the object.
      java.lang.Object toJavaObject()
      Converts this NSObject into an equivalent object of the Java Runtime Environment.
      java.lang.String toString()
      Generates a string representation of the date.
      (package private) void toXML​(java.lang.StringBuilder xml, int level)
      Generates the XML representation of the object (without XML headers or enclosing plist-tags).
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • date

        private final java.util.Date date
      • sdfDefault

        private static final java.text.SimpleDateFormat sdfDefault
      • sdfGnuStep

        private static final java.text.SimpleDateFormat sdfGnuStep
    • Constructor Detail

      • NSDate

        public NSDate​(byte[] bytes)
        Creates new NSDate instance from its binary representation.
        Parameters:
        bytes - The binary date representation.
      • NSDate

        public NSDate​(byte[] bytes,
                      int startIndex,
                      int endIndex)
        Creates a new NSDate instance from its binary representation.
        Parameters:
        bytes - The byte array containing the date data.
        startIndex - The index within the array at which the date data begins.
        endIndex - The index within the array at which the data date ends.
      • NSDate

        public NSDate​(java.lang.String textRepresentation)
               throws java.text.ParseException
        Creates a new NSDate instance from is textual representation. The textual representation must adhere to one of the following patterns. For XML property lists: yyyy-MM-dd'T'HH:mm:ss'Z' For ASCII property lists: yyyy-MM-dd HH:mm:ss Z
        Parameters:
        textRepresentation - The textual representation of the date.
        Throws:
        java.text.ParseException - If the date could not be parsed, i.e. it does not match the expected pattern.
      • NSDate

        public NSDate​(java.util.Date d)
        Creates a new NSDate instance.
        Parameters:
        d - The date.
    • Method Detail

      • parseDateString

        private static java.util.Date parseDateString​(java.lang.String textRepresentation)
                                               throws java.text.ParseException
        Parses a date string and creates a Java Date object from it. This function is synchronized because the underlying SimpleDateFormat instances are not thread-safe.
        Parameters:
        textRepresentation - The date string as found in an ASCII or XML property list
        Returns:
        The parsed Date
        Throws:
        java.text.ParseException - If the given string cannot be parsed.
        See Also:
        DateFormat.parse(java.lang.String)
      • makeDateString

        private static java.lang.String makeDateString​(java.util.Date date)
        Generates a string representation of a Java Date object. The string is formatted according to the specification for XML property list dates.
        Parameters:
        date - The date which should be represented.
        Returns:
        The string representation of the date.
      • makeDateStringGnuStep

        private static java.lang.String makeDateStringGnuStep​(java.util.Date date)
        Generates a string representation of a Java Date object. The string is formatted according to the specification for GnuStep ASCII property list dates.
        Parameters:
        date - The date which should be represented.
        Returns:
        The string representation of the date.
      • getDate

        public java.util.Date getDate()
        Gets the date.
        Returns:
        The date.
      • 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
      • clone

        public NSDate clone()
        Description copied from class: NSObject
        Creates and returns a deep copy of this instance.
        Specified by:
        clone in class NSObject
        Returns:
        A clone of this instance.
      • toXML

        void toXML​(java.lang.StringBuilder xml,
                   int level)
        Description copied from class: NSObject
        Generates the XML representation of the object (without XML headers or enclosing plist-tags).
        Specified by:
        toXML in class NSObject
        Parameters:
        xml - The StringBuilder onto which the XML representation is appended.
        level - The indentation level of the object.
      • toBinary

        void toBinary​(BinaryPropertyListWriter out)
               throws java.io.IOException
        Description copied from class: NSObject
        Generates the binary representation of the object.
        Specified by:
        toBinary in class NSObject
        Parameters:
        out - The output stream to serialize the object to.
        Throws:
        java.io.IOException - If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
      • toString

        public java.lang.String toString()
        Generates a string representation of the date.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string representation of the date.
        See Also:
        Date.toString()
      • toJavaObject

        public java.lang.Object toJavaObject()
        Description copied from class: NSObject
        Converts this NSObject into an equivalent object of the Java Runtime Environment.
        • NSArray objects are converted to arrays.
        • NSDictionary objects are converted to objects extending the Map class.
        • NSSet objects are converted to objects extending the Set class.
        • NSNumber objects are converted to primitive number values (int, long, double or boolean).
        • NSString objects are converted to String objects.
        • NSData objects are converted to byte arrays.
        • NSDate objects are converted to Date objects.
        • UID objects are converted to byte arrays.
        Specified by:
        toJavaObject in class NSObject
        Returns:
        A native java object representing this NSObject's value.
      • compareTo

        public int compareTo​(NSObject o)
      • toASCII

        protected void toASCII​(java.lang.StringBuilder ascii,
                               int level)
        Description copied from class: NSObject
        Generates the ASCII representation of this object. The generated ASCII representation does not end with a newline. Complies with the Old-Style ASCII Property Lists definition.
        Specified by:
        toASCII in class NSObject
        Parameters:
        ascii - The StringBuilder onto which the ASCII representation is appended.
        level - The indentation level of the object.
      • toASCIIGnuStep

        protected void toASCIIGnuStep​(java.lang.StringBuilder ascii,
                                      int level)
        Description copied from class: NSObject
        Generates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.
        Specified by:
        toASCIIGnuStep in class NSObject
        Parameters:
        ascii - The StringBuilder onto which the ASCII representation is appended.
        level - The indentation level of the object.