Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6Kg9RWSTJzyz6KP9X
30 lines
911 B
Java
30 lines
911 B
Java
package com.ankurm.pdfinvoice;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.text.NumberFormat;
|
|
import java.util.Locale;
|
|
|
|
/**
|
|
* Rupee formatting with Indian digit grouping (12,34,567.00), shared by all three writers.
|
|
* It is a class of our own because Thymeleaf 3.1 refuses to call methods on {@code java.*} types
|
|
* from a template expression ("Calling method 'format' is forbidden for type DecimalFormat").
|
|
*/
|
|
public final class Money {
|
|
|
|
private Money() {}
|
|
|
|
public static String inr(BigDecimal v) {
|
|
NumberFormat f = NumberFormat.getNumberInstance(Locale.of("en", "IN"));
|
|
f.setMinimumFractionDigits(2);
|
|
f.setMaximumFractionDigits(2);
|
|
return "₹ " + f.format(v);
|
|
}
|
|
|
|
/** Template-friendly instance wrapper: {@code ${money.inr(x)}}. */
|
|
public static final class Fmt {
|
|
public String inr(BigDecimal v) {
|
|
return Money.inr(v);
|
|
}
|
|
}
|
|
}
|