thymeleaf,freemarker从对象中获取时间并格式化,同时非空判断
freemarker对象非空判断:${(creditInformationDO.applyEndTime)!}
freemarker从对象中获取时间并格式化:${(creditInformationDO.applyEndTime?string('yyyy年MM月dd日'))!}
注意:
非空判断后台要传递对象
CompanyInformation creditInformationDO = new CompanyInformation();
而不是
CompanyInformation creditInformationDO = null;
thymeleaf非空判断:th:value="${creditInformationDO?.applyEndTime}"
thymeleaf从对象中获取时间并格式化:th:value="${#dates.format(creditInformationDO?.applyEndTime, 'yyyy-MM-dd')}"
或
th:value="${#calendars.format(creditInformationDO?.applyEndTime,'yyyy-MM-dd')}"