[bugfix]auto config timezone for Jackson#2197
[bugfix]auto config timezone for Jackson#2197cdphantom wants to merge 7 commits intoapache:masterfrom
Conversation
…hub.com/cdphantom/hertzbeat into bugfix/auto-config-timezone-for-Jackson
| } | ||
| LocalTime silentStart = alertSilence.getPeriodStart().toLocalTime(); | ||
| LocalTime silentEnd = alertSilence.getPeriodEnd().toLocalTime(); | ||
| // 判断是否为静默时间段 |
There was a problem hiding this comment.
Should be translated into Chinese.
|
cc @Calvin979 hi, please help take a review if have time. |
| static-path-pattern: /** | ||
| jackson: | ||
| default-property-inclusion: ALWAYS | ||
| time-zone: ${TZ:Asia/Shanghai} |
There was a problem hiding this comment.
due the #2122 support config time-zone in webui, can this be removed? @Calvin979 @cdphantom
There was a problem hiding this comment.
due the #2122 support config time-zone in webui, can this be removed? @Calvin979 @cdphantom
Yes, it can be removed. @cdphantom
| private boolean isSilentPeriod(LocalTime silentStart, LocalTime silentEnd) { | ||
| if (null == silentStart || null == silentEnd) { | ||
| return false; | ||
| } | ||
| LocalTime nowLocalTime = ZonedDateTime.now().toLocalTime(); | ||
| log.info("nowLocalTime:{}, silentStart:{}, silentEnd:{}, SystemDefaultTimeZoneId:{}", nowLocalTime, silentStart, silentEnd, ZoneId.systemDefault()); | ||
| // 如果静默结束时间小于静默开始时间,意味着静默期跨越了午夜 | ||
| if (silentEnd.isBefore(silentStart)) { | ||
| // 当前时间在午夜之前且大于等于静默开始时间,或者在午夜之后且小于静默结束时间 | ||
| return nowLocalTime.isAfter(silentStart) || nowLocalTime.isBefore(silentEnd); | ||
| } else { | ||
| // 当前时间在静默开始和结束时间之间 | ||
| return nowLocalTime.isAfter(silentStart) && nowLocalTime.isBefore(silentEnd); |
There was a problem hiding this comment.
hi the code comments need to be in English, and suggest use log.debug or trace instead of log.info("nowLocalTime to aviod too many repeated, unimportant logs.
@tomsun28 The coding is right. It can apply to cross-day configuration as well. |


What's changed?
Checklist
Add or update API