From 8a4908d29df2cc02a3358da73c4b1666a50dda23 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 24 Jun 2021 15:08:35 +0200 Subject: [PATCH] TestUtils: Set UTC timezone and add formatUTCDate() --- .../src/test/java/org/pgpainless/util/TestUtils.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pgpainless-core/src/test/java/org/pgpainless/util/TestUtils.java b/pgpainless-core/src/test/java/org/pgpainless/util/TestUtils.java index dae58c80..c963a8a9 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/util/TestUtils.java +++ b/pgpainless-core/src/test/java/org/pgpainless/util/TestUtils.java @@ -23,10 +23,14 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.Random; +import java.util.TimeZone; public class TestUtils { public static SimpleDateFormat UTC_PARSER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); + static { + UTC_PARSER.setTimeZone(TimeZone.getTimeZone("UTC")); + } public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; private static final Random RANDOM = new Random(); @@ -38,6 +42,10 @@ public class TestUtils { } } + public static String formatUTCDate(Date date) { + return UTC_PARSER.format(date); + } + public static int getNumberOfItemsInIterator(Iterator iterator) { int num = 0; while (iterator.hasNext()) {