Skip to content

customSeparator for price purpose#3

Open
samueljl wants to merge 1 commit intobliblidotcom:masterfrom
samueljl:master
Open

customSeparator for price purpose#3
samueljl wants to merge 1 commit intobliblidotcom:masterfrom
samueljl:master

Conversation

@samueljl
Copy link

No description provided.

Handlebars handlebars = new Handlebars()
.with(templateLoader)
.with(templateCache);
handlebars.registerHelper("customSeparator", (context, options) -> customSeparator((Double) context, options));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not all user need this function


public String customSeparator(Double data, Options options) {
String separator = (String) options.hash.getOrDefault("separator", ".");
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create new DecimalFormatSymbols every time customSeparator method invoked?

String separator = (String) options.hash.getOrDefault("separator", ".");
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
decimalFormatSymbols.setGroupingSeparator(separator.charAt(0));
DecimalFormat decimalFormat = new DecimalFormat("###,###", decimalFormatSymbols);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcode format?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants