]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla Bug 28078
authorJeremias Maerki <jeremias@apache.org>
Sat, 3 Apr 2004 08:30:08 +0000 (08:30 +0000)
committerJeremias Maerki <jeremias@apache.org>
Sat, 3 Apr 2004 08:30:08 +0000 (08:30 +0000)
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.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197485 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/pdf/PDFInfo.java
src/java/org/apache/fop/pdf/PDFObject.java

index e9833082c74ba913eb117c093ab19adcaa316cfd..e65e8e3ef2af739ceeb9532a51b08d005fea4809 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.pdf;
 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 @@ public class PDFInfo extends PDFObject {
             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);
index 272cd01c744f659832eed521f8018be0467f2d4b..95047be14456176e97572a30f8220d5fe6ba48c7 100644 (file)
@@ -21,6 +21,8 @@ package org.apache.fop.pdf;
 // 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;
@@ -221,5 +223,21 @@ public abstract class PDFObject {
             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) + "'";
+    }
 
 }