From b8fbb1d6d1d6f9e577f3a4b2bbcf050622c2471c Mon Sep 17 00:00:00 2001 From: Tilman Hausherr Date: Thu, 10 Aug 2023 04:28:19 +0000 Subject: [PATCH] PDFBOX-5645: make UTC TZ static final, as suggested by Daniel Gredler git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1911582 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/fontbox/ttf/TTFDataStream.java | 4 +++- .../src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fontbox/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java b/fontbox/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java index ce877a970e8..ae59bd84be3 100644 --- a/fontbox/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java +++ b/fontbox/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java @@ -32,6 +32,8 @@ */ abstract class TTFDataStream implements Closeable { + private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC"); + TTFDataStream() { } @@ -208,7 +210,7 @@ public short readSignedShort() throws IOException public Calendar readInternationalDate() throws IOException { long secondsSince1904 = readLong(); - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + Calendar cal = Calendar.getInstance(TIMEZONE_UTC); cal.set(1904, 0, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); long millisFor1904 = cal.getTimeInMillis(); diff --git a/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java b/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java index f4bb96a5000..52ce8f36563 100755 --- a/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java +++ b/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java @@ -54,6 +54,8 @@ public final class TTFSubsetter private static final byte[] PAD_BUF = new byte[] { 0, 0, 0 }; + private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC"); + private final TrueTypeFont ttf; private final CmapLookup unicodeCmap; private final SortedMap uniToGID; @@ -1084,7 +1086,7 @@ private void writeUint8(DataOutputStream out, int i) throws IOException private void writeLongDateTime(DataOutputStream out, Calendar calendar) throws IOException { // inverse operation of TTFDataStream.readInternationalDate() - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + Calendar cal = Calendar.getInstance(TIMEZONE_UTC); cal.set(1904, 0, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); long millisFor1904 = cal.getTimeInMillis();