Browse Source

Bugzilla #53185: Unify date formatting between FOP and XGC as well as tidying the date format code. Submitted by Robert Meyer.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1336129 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_1rc1old
Glenn Adams 12 years ago
parent
commit
1c9c25bd5b
3 changed files with 8 additions and 50 deletions
  1. BIN
      lib/xmlgraphics-commons-1.5svn.jar
  2. 5
    50
      src/java/org/apache/fop/pdf/PDFInfo.java
  3. 3
    0
      status.xml

BIN
lib/xmlgraphics-commons-1.5svn.jar View File


+ 5
- 50
src/java/org/apache/fop/pdf/PDFInfo.java View File

@@ -21,12 +21,11 @@ package org.apache.fop.pdf;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

import org.apache.xmlgraphics.util.DateFormatUtil;

/**
* class representing an /Info object
*/
@@ -235,58 +234,14 @@ public class PDFInfo extends PDFObject {
return bout.toByteArray();
}

/**
* Returns a SimpleDateFormat instance for formatting PDF date-times.
* @return a new SimpleDateFormat instance
*/
protected static SimpleDateFormat getPDFDateFormat() {
SimpleDateFormat df = new SimpleDateFormat("'D:'yyyyMMddHHmmss", Locale.ENGLISH);
df.setTimeZone(TimeZone.getTimeZone("GMT"));
return df;
}

/**
* Formats a date/time according to the PDF specification (D:YYYYMMDDHHmmSSOHH'mm').
* @param time date/time value to format
* @param tz the time zone
* @return the requested String representation
*/
protected static String formatDateTime(Date time, TimeZone tz) {
Calendar cal = Calendar.getInstance(tz, Locale.ENGLISH);
cal.setTime(time);

int offset = cal.get(Calendar.ZONE_OFFSET);
offset += cal.get(Calendar.DST_OFFSET);

// DateFormat is operating on GMT so adjust for time zone offset
Date dt1 = new Date(time.getTime() + offset);
StringBuffer sb = new StringBuffer();
sb.append(getPDFDateFormat().format(dt1));

offset /= (1000 * 60); // Convert to minutes

if (offset == 0) {
sb.append('Z');
} else {
if (offset > 0) {
sb.append('+');
} else {
sb.append('-');
}
int offsetHour = Math.abs(offset / 60);
int offsetMinutes = Math.abs(offset % 60);
if (offsetHour < 10) {
sb.append('0');
}
sb.append(Integer.toString(offsetHour));
sb.append('\'');
if (offsetMinutes < 10) {
sb.append('0');
}
sb.append(Integer.toString(offsetMinutes));
sb.append('\'');
}
return sb.toString();
protected static String formatDateTime(final Date time, TimeZone tz) {
return DateFormatUtil.formatPDFDate(time, tz);
}

/**
@@ -294,7 +249,7 @@ public class PDFInfo extends PDFObject {
* @param time date/time value to format
* @return the requested String representation
*/
protected static String formatDateTime(Date time) {
protected static String formatDateTime(final Date time) {
return formatDateTime(time, TimeZone.getDefault());
}
}

+ 3
- 0
status.xml View File

@@ -63,6 +63,9 @@
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
<action context="Layout" dev="GA" type="fix" fixes-bug="53185" due-to="Robert Meyer">
Unify date formatting between FOP and XGC as well as tidying the date format code.
</action>
<action context="Layout" dev="GA" type="fix" fixes-bug="45715" due-to="Luis Bernardo">
Break before (break-before) not respected on blocks nested in inlines.
</action>

Loading…
Cancel
Save