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
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM