Reputation: 320
I'm using spring. I want to display all the numbers on my site in US format.
Eg: 1000000000 should be displayed as 1,000,000,000.
Is there any jquery available for doing this? os any other method? thanks.
Upvotes: 0
Views: 171
Reputation: 8362
If you are using JSP as the Spring view technology, you can use the formatNumber
tag in order to display a number based on the locale:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatNumber type="number" value="1000000" />
If you want to make sure that the US locale is used, add this before the formatNumber
tag:
<fmt:setLocale value="en_US"/>
You shouldn't use jQuery for this, it will only slow your web page down unnecessarily. It is better to send the number already formatted to the client, than doing the formatting by running a script on the web browser.
Upvotes: 1