diff --git a/src/main/java/org/appng/application/manager/service/ManagerService.java b/src/main/java/org/appng/application/manager/service/ManagerService.java index 4a6cfd7..8fd87fc 100644 --- a/src/main/java/org/appng/application/manager/service/ManagerService.java +++ b/src/main/java/org/appng/application/manager/service/ManagerService.java @@ -20,6 +20,8 @@ import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -1221,14 +1223,10 @@ private Selection getTimezoneSelection(Locale locale, String timeZone) { value.setId(MessageConstants.TIMEZONE); timezoneSelection.setTitle(value); timezoneSelection.setType(SelectionType.SELECT); - List ids = Arrays.asList(TimeZone.getAvailableIDs()); - Collections.sort(ids); - List timeZones = new ArrayList<>(); - for (String id : ids) { - if (id.matches("(Africa|America|Antarctica|Asia|Atlantic|Australia|Europe|Indian|Pacific).*")) { - timeZones.add(TimeZone.getTimeZone(id)); - } - } + String allowedTimeZones = "(Africa|America|Antarctica|Asia|Atlantic|Australia|Europe|Indian|Pacific).*"; + List timeZones = Arrays.asList(TimeZone.getAvailableIDs()).stream() + .filter(id -> id.matches(allowedTimeZones)).sorted().map(id -> TimeZone.getTimeZone(id)) + .collect(Collectors.toList()); String groupName = ""; for (TimeZone tz : timeZones) { @@ -1253,12 +1251,9 @@ private Selection getTimezoneSelection(Locale locale, String timeZone) { groupName = area; Option opt = new Option(); String locationName = timezoneMessages.getMessage(areaKey + "." + location, new Object[0], locale); - double offset = (double) tz.getRawOffset() / 1000 / 60 / 60; - int hours = (int) offset; - int minutes = Math.abs((int) (60 * (double) (offset - hours))); - String gmtTimezone = "GMT" + (offset >= 0 ? "+" : "") + StringUtils.leftPad(String.valueOf(hours), 2, "0") - + ":" + StringUtils.leftPad(String.valueOf(minutes), 2, "0"); - opt.setName(locationName + " (" + gmtTimezone + ")"); + ZoneOffset zoneOffset = LocalDateTime.now().atZone(tz.toZoneId()).getOffset(); + String offset = "Z".equals(zoneOffset.getId()) ? "" : zoneOffset.getId(); + opt.setName(locationName + " (UTC" + offset + ")"); opt.setValue(id); opt.setSelected(id.equals(timeZone)); group.getOptions().add(opt); diff --git a/src/test/resources/xml/SubjectsTest-testCreate-action.xml b/src/test/resources/xml/SubjectsTest-testCreate-action.xml index 560da99..8998248 100644 --- a/src/test/resources/xml/SubjectsTest-testCreate-action.xml +++ b/src/test/resources/xml/SubjectsTest-testCreate-action.xml @@ -110,501 +110,501 @@ Timezone - - - - - - - - - diff --git a/src/test/resources/xml/SubjectsTest-testCreateNameExists.xml b/src/test/resources/xml/SubjectsTest-testCreateNameExists.xml index 5f4cd90..c30c496 100644 --- a/src/test/resources/xml/SubjectsTest-testCreateNameExists.xml +++ b/src/test/resources/xml/SubjectsTest-testCreateNameExists.xml @@ -114,501 +114,501 @@ Timezone - - - - - - - - - diff --git a/src/test/resources/xml/SubjectsTest-testCreateValidationFail.xml b/src/test/resources/xml/SubjectsTest-testCreateValidationFail.xml index fbd4adc..73c9019 100644 --- a/src/test/resources/xml/SubjectsTest-testCreateValidationFail.xml +++ b/src/test/resources/xml/SubjectsTest-testCreateValidationFail.xml @@ -130,501 +130,501 @@ Timezone - - - - - - - - - diff --git a/src/test/resources/xml/SubjectsTest-testShowOne.xml b/src/test/resources/xml/SubjectsTest-testShowOne.xml index f1c8d8e..2d0810d 100644 --- a/src/test/resources/xml/SubjectsTest-testShowOne.xml +++ b/src/test/resources/xml/SubjectsTest-testShowOne.xml @@ -79,501 +79,501 @@ Timezone - - - - - - - - - diff --git a/src/test/resources/xml/SubjectsTest-testUpdate-action.xml b/src/test/resources/xml/SubjectsTest-testUpdate-action.xml index 459eec5..d725722 100644 --- a/src/test/resources/xml/SubjectsTest-testUpdate-action.xml +++ b/src/test/resources/xml/SubjectsTest-testUpdate-action.xml @@ -118,501 +118,501 @@ Timezone - - - - - - - - -