IDEMPIERE-5093 Scheduler cron pattern scheduling is always using server time zone (#1348)
- Fix unit test. - Fix server monitor error out if AD_ClientInfo.TimeZone has invalid value.
This commit is contained in:
parent
ad7f78e3c1
commit
f5a0a0a2f6
|
@ -926,10 +926,16 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
return "";
|
return "";
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
|
DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
|
||||||
MClientInfo clientInfo = MClientInfo.get(AD_Client_ID);
|
MClientInfo clientInfo = MClientInfo.get(AD_Client_ID);
|
||||||
if (!Util.isEmpty(clientInfo.getTimeZone()))
|
if (!Util.isEmpty(clientInfo.getTimeZone())) {
|
||||||
|
try {
|
||||||
formatter = formatter.withZone(ZoneId.of(clientInfo.getTimeZone()));
|
formatter = formatter.withZone(ZoneId.of(clientInfo.getTimeZone()));
|
||||||
else
|
} catch (Exception e) {
|
||||||
|
//fallback to default
|
||||||
formatter = formatter.withZone(ZoneId.systemDefault());
|
formatter = formatter.withZone(ZoneId.systemDefault());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formatter = formatter.withZone(ZoneId.systemDefault());
|
||||||
|
}
|
||||||
return formatter.format(date.toInstant().truncatedTo(ChronoUnit.SECONDS));
|
return formatter.format(date.toInstant().truncatedTo(ChronoUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class MSchedulerTest extends AbstractTestCase {
|
||||||
cal2.setTimeZone(tz2);
|
cal2.setTimeZone(tz2);
|
||||||
cal2.setTimeInMillis(System.currentTimeMillis());
|
cal2.setTimeInMillis(System.currentTimeMillis());
|
||||||
hour = cal2.get(Calendar.HOUR_OF_DAY);
|
hour = cal2.get(Calendar.HOUR_OF_DAY);
|
||||||
if (hour > 17) {
|
if (hour >= 17) {
|
||||||
cal2.add(Calendar.DAY_OF_MONTH, 1);
|
cal2.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
}
|
}
|
||||||
cal2.set(Calendar.HOUR_OF_DAY, 17);
|
cal2.set(Calendar.HOUR_OF_DAY, 17);
|
||||||
|
@ -126,7 +126,7 @@ public class MSchedulerTest extends AbstractTestCase {
|
||||||
assertFalse(cal2.getTimeInMillis() == ts1.getTime(), "Un-expected date next run");
|
assertFalse(cal2.getTimeInMillis() == ts1.getTime(), "Un-expected date next run");
|
||||||
|
|
||||||
//test with default + 2hour time zone
|
//test with default + 2hour time zone
|
||||||
clientInfo.setTimeZone(tz2.getID());
|
clientInfo.setTimeZone(tz2.toZoneId().getId());
|
||||||
clientInfo.saveEx();
|
clientInfo.saveEx();
|
||||||
CacheMgt.get().reset();
|
CacheMgt.get().reset();
|
||||||
|
|
||||||
|
@ -143,8 +143,8 @@ public class MSchedulerTest extends AbstractTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
if (schedule != null && schedule.get_ID() > 0)
|
if (schedule != null && schedule.get_ID() > 0)
|
||||||
schedule.deleteEx(true);
|
schedule.deleteEx(true);
|
||||||
if (!Util.isEmpty(currentTimeZone, true)) {
|
|
||||||
clientInfo.setTimeZone(currentTimeZone);
|
clientInfo.setTimeZone(currentTimeZone);
|
||||||
|
if (clientInfo.is_Changed()) {
|
||||||
clientInfo.saveEx();
|
clientInfo.saveEx();
|
||||||
CacheMgt.get().reset();
|
CacheMgt.get().reset();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue