【feat】 优化调整time类型字段
This commit is contained in:
parent
d087e1b8c5
commit
2ef79ab159
@ -85,10 +85,12 @@ public class DataUtil {
|
||||
break;
|
||||
case "date":
|
||||
case "datetime":
|
||||
case "time":
|
||||
case "boolean":
|
||||
result = type;
|
||||
break;
|
||||
case "time":
|
||||
result = "time(3)";
|
||||
break;
|
||||
case "long":
|
||||
case "int":
|
||||
result = "int(" + length + ")";
|
||||
@ -420,11 +422,30 @@ public class DataUtil {
|
||||
}
|
||||
calendar.setTime(date);
|
||||
return calendar;
|
||||
case "time":
|
||||
return adjustHour(data);
|
||||
default:
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public static String adjustHour(String timeStr) {
|
||||
// 提取小时部分并转换为整数
|
||||
int hour = Integer.parseInt(timeStr.substring(0, 2));
|
||||
|
||||
// 减去8小时并处理跨天逻辑
|
||||
int adjustedHour = hour - 8;
|
||||
if (adjustedHour < 0) {
|
||||
adjustedHour += 24; // 处理负数情况(跨天)
|
||||
}
|
||||
|
||||
// 格式化为两位字符串(自动补零)
|
||||
String newHour = String.format("%02d", adjustedHour);
|
||||
|
||||
// 拼接原始字符串的剩余部分(分钟+秒+毫秒)
|
||||
return newHour + timeStr.substring(2);
|
||||
}
|
||||
|
||||
public static boolean isUpdate(String field){
|
||||
switch (field) {
|
||||
case "LastModifiedDate":
|
||||
|
Loading…
Reference in New Issue
Block a user