freemarker常用标签解释三
1 date,time,datetime 日期,时间,时间日期
<#assign test1 = "10/25/1995"?date("MM/dd/yyyy")> <#assign test2 = "15:05:30"?time("HH:mm:ss")> <#assign test3 = "1995-10-25 03:05 PM"?datetime("yyyy-MM-dd hh:mm a")> ${test1} ${test2} ${test3}
输出:
Oct 25, 1995 3:05:30 PM Oct 25, 1995 3:05:00 PM
2 substring 取子串
- ${'abc'?substring(0)} - ${'abc'?substring(1)} - ${'abc'?substring(2)} - ${'abc'?substring(3)} - ${'abc'?substring(0, 0)} - ${'abc'?substring(0, 1)} - ${'abc'?substring(0, 2)} - ${'abc'?substring(0, 3)} - ${'abc'?substring(0, 1)} - ${'abc'?substring(1, 2)} - ${'abc'?substring(2, 3)}
输出结果:
- abc - bc - c - - - a - ab - abc - a - b - c
3 cap_first 首字母大写
${" green mouse"?cap_first} ${"GreEN mouse"?cap_first} ${"- green mouse"?cap_first}
输出:
Green mouse
GreEN mouse
- green mouse
首字母小写: uncap_set
4 首字母大写
${" green mouse"?capitalize} ${"GreEN mouse"?capitalize}
输出:
Green Mouse
Green Mouse
笔记转移,由于在有道云的笔记转移,写的时间可能有点久,如果有错误的地方,请指正