mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4895: Management server fails to start because snapshot policy time zones have day light savings
Changes: - Calendar throws IllegalArgumentException when the hour of the day happens to be skipped due to DST changes. - Fix will ask Calendar to adjust the time accordingly and get the next closest time
This commit is contained in:
parent
643ce4bb90
commit
a00433ff23
|
|
@ -148,7 +148,13 @@ public class DateUtil {
|
|||
scheduleTime.set(Calendar.MINUTE, minutes);
|
||||
scheduleTime.set(Calendar.SECOND, 0);
|
||||
scheduleTime.set(Calendar.MILLISECOND, 0);
|
||||
execDate = scheduleTime.getTime();
|
||||
try {
|
||||
execDate = scheduleTime.getTime();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
scheduleTime.setLenient(true);
|
||||
execDate = scheduleTime.getTime();
|
||||
scheduleTime.setLenient(false);
|
||||
}
|
||||
// XXX: !execDate.after(startDate) is strictly for testing.
|
||||
// During testing we use a test clock which runs much faster than the real clock
|
||||
// So startDate and execDate will always be ahead in the future
|
||||
|
|
@ -168,7 +174,13 @@ public class DateUtil {
|
|||
scheduleTime.set(Calendar.MINUTE, minutes);
|
||||
scheduleTime.set(Calendar.SECOND, 0);
|
||||
scheduleTime.set(Calendar.MILLISECOND, 0);
|
||||
execDate = scheduleTime.getTime();
|
||||
try {
|
||||
execDate = scheduleTime.getTime();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
scheduleTime.setLenient(true);
|
||||
execDate = scheduleTime.getTime();
|
||||
scheduleTime.setLenient(false);
|
||||
}
|
||||
// XXX: !execDate.after(startDate) is strictly for testing.
|
||||
// During testing we use a test clock which runs much faster than the real clock
|
||||
// So startDate and execDate will always be ahead in the future
|
||||
|
|
@ -189,7 +201,13 @@ public class DateUtil {
|
|||
scheduleTime.set(Calendar.MINUTE, minutes);
|
||||
scheduleTime.set(Calendar.SECOND, 0);
|
||||
scheduleTime.set(Calendar.MILLISECOND, 0);
|
||||
execDate = scheduleTime.getTime();
|
||||
try {
|
||||
execDate = scheduleTime.getTime();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
scheduleTime.setLenient(true);
|
||||
execDate = scheduleTime.getTime();
|
||||
scheduleTime.setLenient(false);
|
||||
}
|
||||
// XXX: !execDate.after(startDate) is strictly for testing.
|
||||
// During testing we use a test clock which runs much faster than the real clock
|
||||
// So startDate and execDate will always be ahead in the future
|
||||
|
|
@ -213,7 +231,13 @@ public class DateUtil {
|
|||
scheduleTime.set(Calendar.MINUTE, minutes);
|
||||
scheduleTime.set(Calendar.SECOND, 0);
|
||||
scheduleTime.set(Calendar.MILLISECOND, 0);
|
||||
execDate = scheduleTime.getTime();
|
||||
try {
|
||||
execDate = scheduleTime.getTime();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
scheduleTime.setLenient(true);
|
||||
execDate = scheduleTime.getTime();
|
||||
scheduleTime.setLenient(false);
|
||||
}
|
||||
// XXX: !execDate.after(startDate) is strictly for testing.
|
||||
// During testing we use a test clock which runs much faster than the real clock
|
||||
// So startDate and execDate will always be ahead in the future
|
||||
|
|
@ -226,7 +250,14 @@ public class DateUtil {
|
|||
throw new CloudRuntimeException("Incorrect interval: "+type.toString());
|
||||
}
|
||||
|
||||
return scheduleTime.getTime();
|
||||
try {
|
||||
return scheduleTime.getTime();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
scheduleTime.setLenient(true);
|
||||
Date nextScheduledDate = scheduleTime.getTime();
|
||||
scheduleTime.setLenient(false);
|
||||
return nextScheduledDate;
|
||||
}
|
||||
}
|
||||
|
||||
public static long getTimeDifference(Date date1, Date date2){
|
||||
|
|
|
|||
Loading…
Reference in New Issue