neuland/jade4j

How to format values?

Closed this issue · 4 comments

If I have an integer that I would like to display in ###,##0.00 format, is that possible? If yes, how?

Similarly, if I have a date that I would like to display in MMM dd, yyyy format, is that possible? If yes, how?

You can achieve this using helpers or prepare your model data before passing them into the template.

So, I guess, I would like there to be default helpers for formatting numbers and dates, since these would find wide usage. Can these be included? If I submit a pull request, would that be alright?

Since we try to be unopinionated and the java ecosystem provides a ton of ways to handle formatting, localization and date calculation we see this out of scope for the core jade4j.

When talking about integration with a specific framework there might be more consence and convention of what tools to use for these jobs. I would suggest adding this feature to your jade4j framework adapter of choice or writing your own more opinionated / "batteries included" adapter.

@naltatis, fair enough. I will check the spring-jade4j repository and submit pull requests there as I think that something like number.format(course.seats, "#,##0") and currency.format(bill.total, "###,##0.00") would be useful for most projects.