Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static ScheduleBuildGlobalConfiguration get() {
// time portion (hours, minutes, seconds, etc.) while the date
// portion is ignored.
private transient Date defaultScheduleTime;
private String timeZone;
private ZoneId timeZone;

private String defaultStartTime;

Expand All @@ -61,7 +61,7 @@ public static ScheduleBuildGlobalConfiguration get() {

@DataBoundConstructor
public ScheduleBuildGlobalConfiguration() {
this.timeZone = TimeZone.getDefault().getID();
this.timeZone = ZoneId.systemDefault();
defaultStartTime = "22:00:00";
load();
defaultScheduleLocalTime = LocalTime.parse(defaultStartTime, getTimeFormatter());
Expand Down Expand Up @@ -116,21 +116,21 @@ private LocalTime parseTime(String time) {
}

public String getTimeZone() {
return timeZone;
return timeZone.toString();
}

@DataBoundSetter
public void setTimeZone(String timeZone) {
this.timeZone = timeZone;
try {
this.timeZone = ZoneId.of(timeZone);
} catch (DateTimeException e) {
this.timeZone = ZoneId.systemDefault();
}
save();
}

public ZoneId getZoneId() {
try {
return ZoneId.of(timeZone);
} catch (DateTimeException dte) {
return ZoneId.systemDefault();
}
return timeZone;
}

private DateTimeFormatter getTimeFormatter() {
Expand Down Expand Up @@ -178,7 +178,7 @@ public ListBoxModel doFillTimeZoneItems() {
ListBoxModel items = new ListBoxModel();
Set<String> zoneIds = new TreeSet<>(ZoneId.getAvailableZoneIds());
for (String id : zoneIds) {
if (id.equalsIgnoreCase(timeZone)) {
if (id.equalsIgnoreCase(timeZone.toString())) {
items.add(new ListBoxModel.Option(id, id, true));
} else {
items.add(id);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/hudson.remoting.ClassFilter
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java.time.ZoneRegion
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both classes are needed. The first during saving and the second when loading

java.time.ZoneId