JSTL Format fmt:parseNumber Tag

The <fmt: parseNumber> tag is used to parse the string representation of numbers, currencies and percentage according to the customized formatting pattern.

Syntax Of <fmt: parseNumber> Tag

<fmt: parseNumber attributes> body content </fmt: parseNumber>

Attributes Of <fmt: parseNumber> Tag

valueSpecifies the string value that has to be parsed.
typeSpecifies that the string has to be parsed as number, currency or percentage.
patternSpecifies the custom pattern to parse the string.
varSpecifies the variable name to which the parse value is to be stored.
scopeThe Scope into which the variable number has to be parsed .
parseLocaleIt is used to set the locale during parsing the number .
integerOnlySpecifies that only integer value has to be parsed.


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



<h3>parseNumber Example</h3>

<c: set var="Balance" value="15768.50" />

    <fmt:parseNumber var="tb" type="number" value="${Balance}" />
    <p>Balance:  <c:out value="${tb}" /></p>

    <fmt:parseNumber var="tb" integerOnly="true" type="number" value="${Balance}" />

<p>Balance :  <c:out value="${tb}" /></p>

Details of the Code
<fmt:parseNumber var=”tb” integerOnly=”True” type=”number” value=”${Balance}” /> tag is used to parse the number variable and by using integerOnly as true it displays only the integer value in the output.
<c:out> tag is used to display the value in output.

Steps for Execution

  • Save this file as example.jsp in your eclipse IDE.
  • Now select this jsp file, right mouse click and select Run as ->Run on server


When the execution process is completed successfully we will get the following output:
fmt parseNumber tag output


Previous Tutorial : JSTL Format fmt:formatNumber Tag :: Next Tutorial : JSTL Format fmt:timeZone Tag

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!