How do I format int value 123456789 as 123,456,789 ?
123456789
123,456,789
try this code
public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here DecimalFormat formatter = new DecimalFormat("###,###,###"); System.out.print(formatter.format(123456789)); }
}
you can write a function in jsp block <%! %> and the code inside the main method.
Use JSTL fmt: formatNumber
http://download.oracle.com/docs/cd/E17802_01/products/products/jsp/jstl/1.1/docs/tlddocs/fmt/formatNumber.html
Set your template to #, ## 0
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <fmt:formatNumber pattern="#,##0" value="${value}" />
This will require the JSTL Standard tag library in the WEB-INF / lib folder
http://tomcat.apache.org/taglibs/standard/
Now I'm not 100% sure, but most modern containers provide the "main" jstl.jar API library, and your web application should provide an implementation. In the case of the above link, which should be the standard .jar included in the download.
NumberFormat: http://download.oracle.com/javase/1.4.2/docs/api/java/text/NumberFormat.html
Source: https://habr.com/ru/post/1346150/More articles:Invalid (but not erroneous) return value with a call to Scripting Bridge for Finder under 10.6 - objective-cBest 3D library for simulating robotic motion - pythonCan I disable the combo box in WinForms without sowing it? - c #can support django support group on some columns at the same time as the sum on other columns - pythonCreating a developer API platform in ASP.NET MVC 3? - restMoving jQuery inside p - jqueryHow to insert an element into a selectable control - jqueryCodeIgniter - functions available in several controllers - functionHow to use form-based authentication with jQuery and Ajax? - jqueryJava: a fast / elegant way to check for null - javaAll Articles