@Override protected void toASCII(StringBuilder ascii, int level) { this.indent(ascii, level); ascii.append('"'); ascii.append(makeDateString(this.date)); ascii.append('"'); }
@Override protected void toASCIIGnuStep(StringBuilder ascii, int level) { this.indent(ascii, level); ascii.append("<*D"); ascii.append(makeDateStringGnuStep(this.date)); ascii.append('>'); } }
/** * Attempts to parse a plain string as a date if possible. * * @return A NSDate if the string represents such an object. Otherwise a NSString is returned. */ private NSObject parseDateString() { String numericalString = this.parseString(); if (numericalString.length() > 4 && numericalString.charAt(4) == DATE_DATE_FIELD_DELIMITER) { try { return new NSDate(numericalString); } catch(Exception ex) { //An exception occurs if the string is not a date but just a string } } return new NSString(numericalString); }
private static Date deserializeDate(NSDate date, Class<?> clazz) { if (clazz == Date.class) { //short circuit return date.getDate(); } if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) { //fallback return date.getDate(); } Date result = (Date) getInstance(clazz); result.setTime(date.getDate().getTime()); return result; }
/** * Creates a new NSDate instance from is textual representation. * The textual representation must adhere to one of the following patterns. * For XML property lists: <code>yyyy-MM-dd'T'HH:mm:ss'Z'</code> * For ASCII property lists: <code>yyyy-MM-dd HH:mm:ss Z</code> * * @param 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. */ public NSDate(String textRepresentation) throws ParseException { this.date = parseDateString(textRepresentation); }
return new NSData(getNodeTextContents(n)); } else if (type.equals("date")) { return new NSDate(getNodeTextContents(n));
@Override public boolean equals(Object obj) { return obj.getClass().equals(this.getClass()) && this.date.equals(((NSDate) obj).getDate()); }
@Override void toXML(StringBuilder xml, int level) { this.indent(xml, level); xml.append("<date>"); xml.append(makeDateString(this.date)); xml.append("</date>"); }
return new NSDate((Date) object);
/** * Checks whether a given value is contained in this dictionary. * * @param val The value that will be searched for. * @return Whether the key is contained in this dictionary. */ public boolean containsValue(Date val) { for (NSObject o : this.dict.values()) { if (o.getClass().equals(NSDate.class)) { NSDate dat = (NSDate) o; if (dat.getDate().equals(val)) return true; } } return false; }
return new NSDate(quotedString); } catch (Exception ex) {
return ((NSData)this).bytes(); } else if(this instanceof NSDate) { return ((NSDate)this).getDate(); } else if(this instanceof UID) { return ((UID)this).getBytes();
obj = new NSDate(dateString); } else if (this.accept(DATA_GSINT_BEGIN_TOKEN, DATA_GSREAL_BEGIN_TOKEN)) {
throw new PropertyListFormatException("The given binary property list contains a date object of an unknown type ("+objInfo+")"); return new NSDate(this.bytes, offset + 1, offset + 9);