Rounding up or down in speed

A simple question: can I make the equivalent of Math.ceil and Math.floor in a Velocity template? From what I could find, I would have to use MathTool , but I don't seem to have what I want.

+6
source share
2 answers

I would say that you can work with MathTool.roundToInt() and add / subtract 1, but it should also be possible to provide an object with your methods that can provide what you need.

Also see Velocity Tools 2.0 , MathTool has floor () and ceil () methods.

+3
source

I recommend Tools 2.0 MathTool for maximum flexibility, but Velocity Engine 1.6+ supports static methods, putting the class itself in context. Thus, a quick and easy solution:

context.put ("Math", Math.class);

$ Math.ceil ($ Foo) $ Math.floor ($ bar)

+1
source

Source: https://habr.com/ru/post/886984/


All Articles