FreeMarker date handling

When the variable type is java.sql.Date java.sql.Time java.sql.Timestamp, you don’t need to specify the format;
@Temporal(TemporalType.DATE) annotation makes the ORM framework convert java.util.Date after fetching data from the database The type is automatically converted to the java.sql.Date type, and FreeMarker will automatically recognize its format.

${testDate?date}                          //标准日期转日期字符串

${testDate?datetime}             //标准日期转日期+时间 字符串

${testDate?string("yyyy-MM-dd HH:mm:ss")}  //标准日期转自定格式 字符串


${(testDate?string("yyyy-MM-dd"))!} 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325814608&siteId=291194637