You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2004/04/03 10:30:08 UTC
cvs commit: xml-fop/src/java/org/apache/fop/pdf PDFObject.java PDFInfo.java
jeremias 2004/04/03 00:30:08
Modified: src/java/org/apache/fop/pdf PDFObject.java PDFInfo.java
Log:
Bugzilla Bug 28078
PDFInfo fixed to output the correct timezone for the creation date.
Submitted by: Tomas Soucek <tomas.soucek.at.i.cz>
Patch not applied as given. I moved the formatting of the date/time into PDFObject avoiding the inner class.
Revision Changes Path
1.5 +18 -0 xml-fop/src/java/org/apache/fop/pdf/PDFObject.java
Index: PDFObject.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFObject.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PDFObject.java 2 Apr 2004 09:14:51 -0000 1.4
+++ PDFObject.java 3 Apr 2004 08:30:08 -0000 1.5
@@ -21,6 +21,8 @@
// 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;
@@ -220,6 +222,22 @@
} else {
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) + "'";
}
}
1.6 +1 -4 xml-fop/src/java/org/apache/fop/pdf/PDFInfo.java
Index: PDFInfo.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFInfo.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PDFInfo.java 2 Apr 2004 09:14:51 -0000 1.5
+++ PDFInfo.java 3 Apr 2004 08:30:08 -0000 1.6
@@ -21,7 +21,6 @@
import java.util.Date;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.text.SimpleDateFormat;
/**
* class representing an /Info object
@@ -156,10 +155,8 @@
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);
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org