From 4451fa876ab3c4f84ef54e1207bcfd38d0e82401 Mon Sep 17 00:00:00 2001 From: Alex Bishop Date: Tue, 29 Dec 2020 10:52:08 +0000 Subject: [PATCH] =?UTF-8?q?BAU=20=E2=80=94=20Use=20yyyy=20(year)=20instead?= =?UTF-8?q?=20of=20YYYY=20(week=20year)=20when=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Around the beginning or the end of the year, the week year (YYYY) is not always the same as what we usually think of as the year (yyyy). --- .../gov/pay/publicauth/json/DateTimeStringSerializer.java | 2 +- .../uk/gov/pay/publicauth/resources/PublicAuthResource.java | 2 +- .../java/uk/gov/pay/publicauth/it/PublicAuthResourceIT.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/uk/gov/pay/publicauth/json/DateTimeStringSerializer.java b/src/main/java/uk/gov/pay/publicauth/json/DateTimeStringSerializer.java index c76a3930..7025cdd2 100644 --- a/src/main/java/uk/gov/pay/publicauth/json/DateTimeStringSerializer.java +++ b/src/main/java/uk/gov/pay/publicauth/json/DateTimeStringSerializer.java @@ -20,6 +20,6 @@ private DateTimeStringSerializer(Class t) { @Override public void serialize(ZonedDateTime zonedDateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { - jsonGenerator.writeString(DateTimeFormatter.ofPattern("dd MMM YYYY - HH:mm").format(zonedDateTime)); + jsonGenerator.writeString(DateTimeFormatter.ofPattern("dd MMM yyyy - HH:mm").format(zonedDateTime)); } } diff --git a/src/main/java/uk/gov/pay/publicauth/resources/PublicAuthResource.java b/src/main/java/uk/gov/pay/publicauth/resources/PublicAuthResource.java index 065a6c4f..66376e05 100644 --- a/src/main/java/uk/gov/pay/publicauth/resources/PublicAuthResource.java +++ b/src/main/java/uk/gov/pay/publicauth/resources/PublicAuthResource.java @@ -53,7 +53,7 @@ public class PublicAuthResource { private static final String TOKEN_LINK_FIELD = "token_link"; private static final String TOKEN_FIELD = "token"; private static final String DESCRIPTION_FIELD = "description"; - private static final String REVOKED_DATE_FORMAT_PATTERN = "dd MMM YYYY"; + private static final String REVOKED_DATE_FORMAT_PATTERN = "dd MMM yyyy"; private final TokenService tokenService; diff --git a/src/test/java/uk/gov/pay/publicauth/it/PublicAuthResourceIT.java b/src/test/java/uk/gov/pay/publicauth/it/PublicAuthResourceIT.java index 5f271554..c40e13fd 100644 --- a/src/test/java/uk/gov/pay/publicauth/it/PublicAuthResourceIT.java +++ b/src/test/java/uk/gov/pay/publicauth/it/PublicAuthResourceIT.java @@ -47,7 +47,7 @@ @SuppressWarnings("OptionalGetWithoutIsPresent") public class PublicAuthResourceIT { - private static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("dd MMM YYYY - HH:mm"); + private static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("dd MMM yyyy - HH:mm"); private static final String SALT = "$2a$10$IhaXo6LIBhKIWOiGpbtPOu"; private static final String BEARER_TOKEN = "testbearertoken"; @@ -536,7 +536,7 @@ public void respondWith200_whenSingleTokenIsRevokedByTokenLink() { revokeSingleToken(ACCOUNT_ID, "{\"token_link\" : \"" + TOKEN_LINK.toString() + "\"}") .statusCode(200) - .body("revoked", is(ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("dd MMM YYYY")))); + .body("revoked", is(ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("dd MMM yyyy")))); Optional revokedInDb = app.getDatabaseHelper().lookupColumnForTokenTable("revoked", "token_link", TOKEN_LINK.toString()); assertThat(revokedInDb.isPresent(), is(true)); @@ -548,7 +548,7 @@ public void respondWith200_whenSingleTokenIsRevokedByToken() { String fullBearerToken = BEARER_TOKEN + "qgs2ot3itqer7ag9mvvbs8snqb5jfas3"; revokeSingleToken(ACCOUNT_ID, "{\"token\" : \"" + fullBearerToken + "\"}") .statusCode(200) - .body("revoked", is(ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("dd MMM YYYY")))); + .body("revoked", is(ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("dd MMM yyyy")))); Optional revokedInDb = app.getDatabaseHelper().lookupColumnForTokenTable("revoked", "token_link", TOKEN_LINK.toString()); assertThat(revokedInDb.isPresent(), is(true));