Turn Desktop View Off

In JSTL the tag <fmt: format Number> is been preferred for the showing Number formation In different Format. There are some attributes are used in the tag for proper display.


Like Value, type, Pattern, var etc. in Value attribute the required value is been filled as per recommendation the other one we use Type this attribute used to specify that which kind of value will be formatted will it be Number, Currency or Percentage. And in Last we has to use Pattern and var the var attribute used to give a variable name that store the value to be formatted.

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>



               <title>&lt;fmt:formatNumber&gt;Tag Example In J.S.P</title>



                 <center><h2>Demo Of Number Format</h2></center>

                <c:set var="format" value="3400086.789"/>

                <p><center><b>Formatted Number (1): <fmt:formatNumber value="${format}"


                <p><center><b>Formatted Number (2): <fmt:formatNumber type="number"

                          maxIntegerDigits="2" value="${format}" /></p></b></center>

                <p><center><b>Formatted Number (3): <fmt:formatNumber type="number"

                          groupingUsed="true" value="${format}" /></p></b></center>

                <p><b><center>Formatted Number (4): <fmt:formatNumber type="percent"

                          maxIntegerDigits="3" value="${format}" /></p></center></b>

                 <p><b><center>Formatted Number (5): <fmt:formatNumber type="number"

                          pattern="###.###E0" value="${format}" /></p></center></b>

                <p><center><b>Currency in USA :

                       <fmt:setLocale value="en_US"/>

                       <fmt:formatNumber value="${format}" type="currency"/>




      JSTL Tag <fmt:format Number>

Here We made a program of <fmt: format Number> first we call the JSTL Library Code in the starting Of program and after then declaring a variable and assures the value we use some required attributes in given codes that will bring the Output as per their phase. Like we use grouping, Decimal place formatting like pattern and currency Mode also. And in the last we closed all the Html tags.

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.