Pass Java function into Velocity template

I’m stuck on this. I have method in my Java class.

public String getCorrectFormatDate(Issue issue){
    Long timespent = issue.getTimeSpent();

        int hours = (int) (timespent / 3600);
        int remainder = (int) (timespent - hours * 3600);
        int min = remainder / 60;
        String result = hours + "h " + min +"min";
        return result;
        return "0";


Also, In my velocity template I have this code

#foreach ($issue in $issues)
        <tr role="row">
            <td colspan="1" class="confluenceTd"><a href="$action.getBaseURL()/browse/${issue.getKey()}">$issue.getKey()</a></td>
            <td colspan="1" class="confluenceTd">$issue.getSummary()</td>
            <td colspan="1" class="confluenceTd">$action.getCorrectFormatDate($issue)</td>

Why this my certain method isnt working?


threw exception java.lang.NullPointerException

I’m not very familiar with velocity templates, but if ${ is for escaping calls to Java in string, then I’d expect it to be applicable for the $action.getBaseURL() part as well.

So should it be something like "${action.getBaseURL()}/browse/${issue.getKey()}" ?