DateFormatter.java
public static String formatDateTime(Object value, Timestamp ts, Time needCheckCdtFirstTime,boolean isTimestamp) {
Calendar cal;
Integer hour = null;
if ( value instanceof Long ) {
cal = isTimestamp && !MaxwellConfig.MYSQL_TIME_ZONE.equals("UTC")
? calendarThreadLocal.get() : calendarUTCThreadLocal.get();
cal.setTimeInMillis(ts.getTime());
} else {
cal = calendarThreadLocal.get();
if(needCheckCdtFirstTime != null){
cal.setTime(needCheckCdtFirstTime);
hour = cal.get(Calendar.HOUR_OF_DAY);
}
cal.clear();
cal.setTimeInMillis(ts.getTime());
}
return formatDateTime(cal,hour);
}
1. 公司rds历史遗留存在两种时区
show VARIABLES like '%time_zone%';
system_time_zone CST
time_zone SYSTEM
----------------
system_time_zone UTC
time_zone SYSTEM
2.夏时令开始时间问题
1991-04-14 02:00:00------>1991-04-14 03:00:00等等
这篇博客探讨了Java中处理日期时间的代码,包括根据不同时区进行转换的逻辑,以及如何处理夏令时变化的问题。文章指出,公司RDS存在CST和UTC两种时区,并详细阐述了在转换过程中如何正确处理时间戳和Calendar对象。
3241

被折叠的 条评论
为什么被折叠?



