Package com.dd.plist
Class NSDate
java.lang.Object
com.dd.plist.NSObject
com.dd.plist.NSDate
- All Implemented Interfaces:
Cloneable,Comparable<NSObject>
The NSDate class wraps a date.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Dateprivate static final longprivate static final SimpleDateFormatprivate static final SimpleDateFormatFields inherited from class com.dd.plist.NSObject
ASCII_LINE_LENGTH, NEWLINE -
Constructor Summary
ConstructorsConstructorDescriptionNSDate(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.Creates a new NSDate instance from is textual representation.Creates a new NSDate instance. -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates and returns a deep copy of this instance.intbooleangetDate()Gets the date.inthashCode()private static StringmakeDateString(Date date) Generates a string representation of a Java Date object.private static StringmakeDateStringGnuStep(Date date) Generates a string representation of a Java Date object.private static DateparseDateString(String textRepresentation) Parses a date string and creates a Java Date object from it.protected voidtoASCII(StringBuilder ascii, int level) Generates the ASCII representation of this object.protected voidtoASCIIGnuStep(StringBuilder ascii, int level) Generates the ASCII representation of this object in the GnuStep format.(package private) voidGenerates the binary representation of the object.Converts this NSObject into an equivalent object of the Java Runtime Environment.toString()Generates a string representation of the date.(package private) voidtoXML(StringBuilder xml, int level) Generates the XML representation of the object (without XML headers or enclosing plist-tags).Methods inherited from class com.dd.plist.NSObject
assignIDs, fromJavaObject, indent, toJavaObject, toXMLPropertyList
-
Field Details
-
date
-
EPOCH
private static final long EPOCH- See Also:
-
sdfDefault
-
sdfGnuStep
-
-
Constructor Details
-
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
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:
ParseException- If the date could not be parsed, i.e. it does not match the expected pattern.
-
NSDate
Creates a new NSDate instance.- Parameters:
d- The date.
-
-
Method Details
-
parseDateString
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:
ParseException- If the given string cannot be parsed.- See Also:
-
makeDateString
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
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
Gets the date.- Returns:
- The date.
-
equals
-
hashCode
public int hashCode() -
clone
Description copied from class:NSObjectCreates and returns a deep copy of this instance. -
toXML
Description copied from class:NSObjectGenerates the XML representation of the object (without XML headers or enclosing plist-tags).- Specified by:
toXMLin classNSObject- Parameters:
xml- TheStringBuilderonto which the XML representation is appended.level- The indentation level of the object.
-
toBinary
Description copied from class:NSObjectGenerates the binary representation of the object.- Specified by:
toBinaryin classNSObject- Parameters:
out- The output stream to serialize the object to.- Throws:
IOException- If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
-
toString
Generates a string representation of the date. -
toJavaObject
Description copied from class:NSObjectConverts this NSObject into an equivalent object of the Java Runtime Environment.NSArrayobjects are converted to arrays.NSDictionaryobjects are converted to objects extending theMapclass.NSSetobjects are converted to objects extending theSetclass.NSNumberobjects are converted to primitive number values (int, long, double or boolean).NSStringobjects are converted toStringobjects.NSDataobjects are converted to byte arrays.NSDateobjects are converted toDateobjects.UIDobjects are converted to byte arrays.
- Specified by:
toJavaObjectin classNSObject- Returns:
- A native java object representing this NSObject's value.
-
compareTo
-
toASCII
Description copied from class:NSObjectGenerates 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:
toASCIIin classNSObject- Parameters:
ascii- TheStringBuilderonto which the ASCII representation is appended.level- The indentation level of the object.
-
toASCIIGnuStep
Description copied from class:NSObjectGenerates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.- Specified by:
toASCIIGnuStepin classNSObject- Parameters:
ascii- TheStringBuilderonto which the ASCII representation is appended.level- The indentation level of the object.
-