feat(REQ-3769) - 调整表单日期组件格式化
This commit is contained in:
parent
5acd4bfe21
commit
e4bc13f060
@ -130,7 +130,7 @@ public class CustomGetFormInstanceModelCmd extends GetFormInstanceModelCmd {
|
||||
try {
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(fieldValue)) {
|
||||
LocalDate dateValue = LocalDate.parse(fieldValue);
|
||||
variables.put(field.getId(), dateValue.toString(field.getParam("fmt").toString()));
|
||||
variables.put(field.getId(), dateValue.toString(fmtConvert(field.getParam("fmt").toString())));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error parsing form date value for process instance {} and task {} with value {}", processInstanceId, taskId, fieldValue, e);
|
||||
@ -378,7 +378,7 @@ public class CustomGetFormInstanceModelCmd extends GetFormInstanceModelCmd {
|
||||
if (variableValue != null) {
|
||||
|
||||
if (variableValue instanceof LocalDate) {
|
||||
field.setValue(((LocalDate) variableValue).toString(field.getParam("fmt").toString()));
|
||||
field.setValue(((LocalDate) variableValue).toString(fmtConvert(field.getParam("fmt").toString())));
|
||||
} else if (variableValue instanceof Date) {
|
||||
field.setValue(DATE_FORMAT.format(((Date) variableValue).toInstant()));
|
||||
} else {
|
||||
@ -391,4 +391,15 @@ public class CustomGetFormInstanceModelCmd extends GetFormInstanceModelCmd {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String fmtConvert(String fmt) {
|
||||
switch (fmt) {
|
||||
case "YYYY-MM-DD HH:mm:ss":
|
||||
return "yyyy-MM-dd HH:mm:ss";
|
||||
case "YYYY-MM-DD HH:mm":
|
||||
return "yyyy-MM-dd HH:mm";
|
||||
default:
|
||||
return "yyyy-MM-dd";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user