freemarker常用标签解释三

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

 

posted @ 2019-02-20 10:57 动手的程序员 阅读( ...) 评论( ...) 编辑 收藏

你可能感兴趣的:(freemarker常用标签解释三)