JSTL Parse Number Example <fmt:parseNumber>

JSTL Parse Number tag is used to parse the numbers, percentage or currency.

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

 <title>JSTL Parse Number Example</title>
    <!-- Setting Locale to US -->
    <fmt:parseNumber value="156.1432" var="test" integerOnly="TRUE" type="NUMBER"></fmt:parseNumber>
    <c:out value="${test}"></c:out>

As you can see above, JSTL Parse Number Tag is used to parse the number. Parse Number Tag in JSTL has following attributes.

1. value : Value attribute provides the number to be parsed.

2. type: Type attribute specifies the type of string to be parsed. It can be NUMBER, PERCENT or CURRENCY.

3. var : Var attribute provides the variable that is used to store the parsed number. This variable can be used later in the jsp.

4. intgerOnly: integerOnly attribute allows to store number in Integer format only. Default value is false.

5. pattern: Pattern attribute provides custom formatting pattern that determines how the string in the value attribute is to be parsed.

6. scope: Scope attribute provides the scope of variable.

<<Previous <<   || Index ||   >>Next >>

No comments:

Post a Comment