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