All is say in the title. I want to transform double in String with 2 decimals.
I tried with the example of quarkus :
@TemplateExtension(namespace = "str")
class StringExtensions {
static String format(String fmt, Object... args) {
return String.format(fmt, args);
}
static String reverse(String val) {
return new StringBuilder(val).reverse().toString();
}
}
And is my template
{str:format('%.2f', total)}
But It always results in NOT_FOUND.
The only way is putting :
static String formatNumber(Double num) {
return String.format("%.2f", num);
}
and change my template :
{total.formatNumber}
Is there a better way ? I used the quarkus-rest-easy-qute et quarkus-qute extension both is the same.