fix: db2 时间格式化

This commit is contained in:
taojinlong 2022-06-28 17:42:05 +08:00
parent 27aa14b6ca
commit 00aeffc8dc

View File

@ -117,6 +117,8 @@ public class Db2QueryProvider extends QueryProvider {
} else { } else {
if (f.getType().equalsIgnoreCase("TIME")) { if (f.getType().equalsIgnoreCase("TIME")) {
fieldName = String.format(Db2Constants.FORMAT_TIME, originField, Db2Constants.DEFAULT_DATE_FORMAT); fieldName = String.format(Db2Constants.FORMAT_TIME, originField, Db2Constants.DEFAULT_DATE_FORMAT);
} else if(f.getType().equalsIgnoreCase("DATE")) {
fieldName = String.format(Db2Constants.FORMAT_DATE, originField, Db2Constants.DEFAULT_DATE_FORMAT);
}else { }else {
fieldName = originField; fieldName = originField;
} }
@ -194,6 +196,8 @@ public class Db2QueryProvider extends QueryProvider {
} else { } else {
if (f.getType().equalsIgnoreCase("TIME")) { if (f.getType().equalsIgnoreCase("TIME")) {
fieldName = String.format(Db2Constants.FORMAT_TIME, originField, Db2Constants.DEFAULT_DATE_FORMAT); fieldName = String.format(Db2Constants.FORMAT_TIME, originField, Db2Constants.DEFAULT_DATE_FORMAT);
} else if(f.getType().equalsIgnoreCase("DATE")) {
fieldName = String.format(Db2Constants.FORMAT_DATE, originField, Db2Constants.DEFAULT_DATE_FORMAT);
}else { }else {
fieldName = originField; fieldName = originField;
} }
@ -857,6 +861,8 @@ public class Db2QueryProvider extends QueryProvider {
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) { if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
if (field.getType().equalsIgnoreCase("TIME")) { if (field.getType().equalsIgnoreCase("TIME")) {
whereName = String.format(Db2Constants.FORMAT_TIME, originName, Db2Constants.DEFAULT_DATE_FORMAT); whereName = String.format(Db2Constants.FORMAT_TIME, originName, Db2Constants.DEFAULT_DATE_FORMAT);
}else if(field.getType().equalsIgnoreCase("DATE")) {
whereName = String.format(Db2Constants.FORMAT_DATE, originName, Db2Constants.DEFAULT_DATE_FORMAT);
}else { }else {
whereName = originName; whereName = originName;
} }
@ -965,6 +971,8 @@ public class Db2QueryProvider extends QueryProvider {
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) { if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
if (field.getType().equalsIgnoreCase("TIME")) { if (field.getType().equalsIgnoreCase("TIME")) {
whereName = String.format(Db2Constants.FORMAT_TIME, originName, Db2Constants.DEFAULT_DATE_FORMAT); whereName = String.format(Db2Constants.FORMAT_TIME, originName, Db2Constants.DEFAULT_DATE_FORMAT);
} else if(field.getType().equalsIgnoreCase("DATE")) {
whereName = String.format(Db2Constants.FORMAT_DATE, originName, Db2Constants.DEFAULT_DATE_FORMAT);
}else { }else {
whereName = originName; whereName = originName;
} }
@ -1068,6 +1076,8 @@ public class Db2QueryProvider extends QueryProvider {
String format = transDateFormat(x.getDateStyle(), x.getDatePattern()); String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
if (x.getType().equalsIgnoreCase("TIME")) { if (x.getType().equalsIgnoreCase("TIME")) {
fieldName = String.format(Db2Constants.FORMAT_TIME, originField, format); fieldName = String.format(Db2Constants.FORMAT_TIME, originField, format);
} else if(x.getType().equalsIgnoreCase("DATE")){
fieldName = String.format(Db2Constants.FORMAT_DATE, originField, format);
}else { }else {
fieldName = String.format(Db2Constants.DATE_FORMAT, originField, format); fieldName = String.format(Db2Constants.DATE_FORMAT, originField, format);
} }