Update set messsage API to parse expires_at with offset When a user, who is in a different timezone from the server, attempts to update the message, this API is called with an offset for expires_at. With this change, such users should be able to update the banner as well. Change-Id: Ia362389ceecc4a2c7ad09c79cede47d93c6e3e27
diff --git a/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/SetMessage.java b/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/SetMessage.java index 1680a3b..f489200 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/SetMessage.java +++ b/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/SetMessage.java
@@ -71,8 +71,12 @@ @Override public Response<?> apply(ConfigResource resource, MessageInput input) - throws AuthException, BadRequestException, ResourceConflictException, - PermissionBackendException, ConfigInvalidException, UnprocessableEntityException { + throws AuthException, + BadRequestException, + ResourceConflictException, + PermissionBackendException, + ConfigInvalidException, + UnprocessableEntityException { permissionBackend.currentUser().check(permission); if (input.message == null) { @@ -100,11 +104,12 @@ try { time = ZonedDateTime.parse( - input.expiresAt, DateTimeFormatter.ofPattern("MM/dd/yyyy, hh:mm a z")) + input.expiresAt, DateTimeFormatter.ofPattern("MM/dd/yyyy, hh:mm a [O][z]")) .withZoneSameInstant(serverZoneId); } catch (IllegalArgumentException e) { throw new BadRequestException( - "Invalid value for expires_at. It must be provided in 'MM/dd/yyyy, hh:mm a z' format"); + "Invalid value for expires_at. It must be provided in 'MM/dd/yyyy, hh:mm a z' or" + + " 'MM/dd/yyyy, hh:mm a O' format"); } cfg.setString( SECTION_MESSAGE,