Freemarker日期格式化处理

基本参数:

  • date: 只显示日期,不显示时间.
    ${createTime?date}${createTime?date('yyyy-MM-dd')}
  • time: 只显示时间,不显示日期
    ${createTime?time}${createTime?time('hh:mm:ss')}
  • datetime: 时间和日期同时显示
    ${createTime}${createTime?datetime('yyyy-MM-dd hh:mm:ss')}${createTime?string('yyyy-MM-dd hh:mm:ss')}

Freemarker预置了一些日期格式

${createTime?string.short}  01:45 PM
${createTime?string.medium}  01:45:09 PM
${createTime?string.long}  01:45:09 PM PST
${createTime?string.full}  01:45:09 PM PST
${createTime?string.xs}  13:45:09-08:00
${createTime?string.iso}  13:45:09-08:00

字符串类型:

日期格式:${book.date?string('yyyy-MM-dd')} 

文/Devid(简书作者)
原文链接:http://www.jianshu.com/p/980aaeea3402
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
原文地址:https://www.cnblogs.com/w1217/p/5972081.html