import java.util.Date;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.text.SimpleDateFormat;
/**
* class representing an /Info object
if (creationDate == null) {
creationDate = new Date();
}
- final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
- final String str = sdf.format(creationDate) + "+00'00'";
bout.write(encode("/CreationDate "));
- bout.write(encodeString("D:" + str));
+ bout.write(encodeString(formatDateTime(creationDate)));
bout.write(encode("\n>>\nendobj\n"));
} catch (IOException ioe) {
log.error("Ignored I/O exception", ioe);
// Java
import java.io.IOException;
import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
return buf;
}*/
}
+
+ /** Formatting pattern for PDF date */
+ protected static final SimpleDateFormat DATE_FORMAT
+ = new SimpleDateFormat("'D:'yyyyMMddHHmmssZ");
+
+ /**
+ * Formats a date/time according to the PDF specification
+ * (D:YYYYMMDDHHmmSSOHH'mm').
+ * @param time date/time value to format
+ * @return the requested String representation
+ */
+ protected String formatDateTime(Date time) {
+ String s = DATE_FORMAT.format(time);
+ int i = s.length() - 2;
+ return s.substring(0, i) + "'" + s.substring(i) + "'";
+ }
}