fix: mysql 时间处理错误

This commit is contained in:
taojinlong 2022-09-28 11:04:02 +08:00
parent 0d7b1f1805
commit 76098ef5c5

View File

@ -117,7 +117,7 @@ public class MysqlQueryProvider extends QueryProvider {
if (f.getType().equalsIgnoreCase("YEAR")) {
fieldName = String.format(MySQLConstants.DATE_FORMAT, "CONCAT(" + originField + ",'-01-01')", MySQLConstants.DEFAULT_DATE_FORMAT);
} else if (f.getType().equalsIgnoreCase("TIME")) {
fieldName = String.format(MySQLConstants.DATE_FORMAT, "CONCAT(1970-01-01 " + originField + ")", MySQLConstants.DEFAULT_DATE_FORMAT);
fieldName = String.format(MySQLConstants.DATE_FORMAT, "CONCAT('1970-01-01', " + originField + ")", MySQLConstants.DEFAULT_DATE_FORMAT);
} else {
fieldName = String.format(MySQLConstants.DATE_FORMAT, originField, MySQLConstants.DEFAULT_DATE_FORMAT);
}
@ -176,7 +176,7 @@ public class MysqlQueryProvider extends QueryProvider {
if (f.getType().equalsIgnoreCase("YEAR")) {
fieldName = String.format(MySQLConstants.DATE_FORMAT, "CONCAT(" + originField + ",'-01-01')", MySQLConstants.DEFAULT_DATE_FORMAT);
} else if (f.getType().equalsIgnoreCase("TIME")) {
fieldName = String.format(MySQLConstants.DATE_FORMAT, "CONCAT(1970-01-01 " + originField + ")", MySQLConstants.DEFAULT_DATE_FORMAT);
fieldName = String.format(MySQLConstants.DATE_FORMAT, "CONCAT('1970-01-01', " + originField + ")", MySQLConstants.DEFAULT_DATE_FORMAT);
} else {
fieldName = String.format(MySQLConstants.DATE_FORMAT, originField, MySQLConstants.DEFAULT_DATE_FORMAT);
}
@ -1140,7 +1140,7 @@ public class MysqlQueryProvider extends QueryProvider {
if (x.getType().equalsIgnoreCase("YEAR")) {
fieldName = String.format(MySQLConstants.DATE_FORMAT, "CONCAT(" + originField + ",'-01-01')", transDateFormat(x.getDateStyle(), x.getDatePattern()));
} else if (x.getType().equalsIgnoreCase("TIME")) {
fieldName = String.format(MySQLConstants.DATE_FORMAT, "CONCAT(1970-01-01 " + originField + ")", MySQLConstants.DEFAULT_DATE_FORMAT);
fieldName = String.format(MySQLConstants.DATE_FORMAT, "CONCAT('1970-01-01', " + originField + ")", MySQLConstants.DEFAULT_DATE_FORMAT);
} else {
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
fieldName = String.format(MySQLConstants.DATE_FORMAT, originField, format);