org.apache.velocity.tools.generic.DateTool
Jfinal可在拦截器中加上request.setAttribute("date", new DateTool()),date你随时可以在.vm的Velocity模板中使用。
关于date,如下所示:
函数举例 显示结果
函数举例 | 显示结果 |
$date | 2008-04-22 |
$date.long | 2008年4月22日下午10时58分54秒 |
$date.medium_time | 22:58:54 |
$date.full_date | 2008年4月22日星期二 |
$date.yyyy | 2008 |
$date.get('default','short') | 2008-4-22 下午10:58 |
$date.get('yyyy-M-d H:m:s') | 2008-4-22 22:58:54 |
$date.whenIs('2008-04-20') | 2 days 22 hours ago |
$date.whenIs('2008-04-20').full | 2 days 22 hours 58 minutes 54 seconds 484 milliseconds ago |
$date.whenIs('2008-04-20').days | -2 |
$date.whenIs('2008-04-20') | 22 hours 58 minutes ago |
$date.whenIs('2008-04-20','2008-04-20') | same time |
$date.difference('2008-04-20', '2008-04-20') | 2 days |
$date.whenIs('2008-04-20').days | -2 |
org.apache.velocity.tools.generic.MathTool
Jfinal可在拦截器中加上request.setAttribute("math", new MathTool()),date你随时可以在.vm的Velocity模板中使用。关于math,如下所示:
函数举例 显示结果
函数举例 | 显示结果 |
$math.add("10","4") | 14 |
$math.sub("100","20") | 80 |
$math.mul("11","7") | 77 |
$math.div("100","5") | 20 |
$math.idiv("100","5") | 20 |
$math.pow("2","5") | 32 |
$math.mod("13","5") | 3 |
$math.max("99","16") | 99 |
$math.min("99","16") | 16 |
$math.abs("-99") | 99 |
\$math.cell("99.26") | $math.cell("99.26") |
$math.floor("99.26") | 99 |
$math.random | 0.7663665545444911 |
$math.random("1","10") | 2 |
$math.roundTo("2","5") | 5.0 |
$math.toInteger("15") | 15 |
$math.toDouble("15") | 15.0 |
$math.toNumber("15") | 15 |
org.apache.velocity.tools.generic.NumberTool
Jfinal可在拦截器中加上request.setAttribute("number", new NumberTool()),date你随时可以在.vm的Velocity模板中使用。关于number,如下所示:
函数举例 显示结果
$number.locale | zh_CN |
$number.format("35") | 35.0 |
$number.integer("35.47") | 35 |
$number.number("35.47") | 35.47 |
$number.percent("0.3547") | 35% |
$number.toNumber("35.47") | 35.47 |
$number.format("#0.00", 35.5659) | 35.56 保留两位小数 |
org.apache.velocity.tools.generic.SortTool
Jfinal可在拦截器中加上request.setAttribute("sorter", new SortTool()),date你随时可以在.vm的Velocity模板中使用。
关于sorter,如下所示:
函数举例 显示结果
函数举例 | 显示结果 |
$sorter.sort(['d','a','b','c']) | [a, b, c, d] |
$sorter.sort([5,1,12,3]) | [1, 3, 5, 12] |