Skip to content

Commit

Permalink
PDFBOX-5645: make UTC TZ static final, as suggested by Daniel Gredler
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1911582 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Aug 10, 2023
1 parent d324b02 commit b8fbb1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*/
abstract class TTFDataStream implements Closeable
{
private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC");

TTFDataStream()
{
}
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, Integer> uniToGID;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b8fbb1d

Please sign in to comment.