Calling class methods (static) from inside a velocity view page

Viewed 24919

Can you call class methods from inside a view page?

Specifically ones that are not passed into the view?

In asp.net MVC I can do this:

<%= SomeClass.FixDateFormat(ViewData.Model.SomeClass.DateCreated) %>
2 Answers

Here is a universal way to call any static method of any class without need for preliminarily context manipulation:

#‌​set($str='test')##
#set($Base64=$str.class.forName('java‌​.util.Base64'))##
​$Base64.getEncoder()‌​.encodeToString($str‌​.getBytes('utf8'))
Related