• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

JSTL Format fmt:parseNumber Tag

February 24, 2014 //  by Krishna Srinivasan//  Leave a Comment

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

Attributes Description
value Specifies the string value that has to be parsed.
type Specifies that the string has to be parsed as number, currency or percentage.
pattern Specifies the custom pattern to parse the string.
var Specifies the variable name to which the parse value is to be stored.
scope The Scope into which the variable number has to be parsed .
parseLocale It is used to set the locale during parsing the number .
integerOnly Specifies that only integer value has to be parsed.

Example

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

<html>
  <head>

    <title>parseNumber</title>
  </head>
  <body>

<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>
  </body>
</html>

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

Output

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

Category: Java EETag: JSTL Tutorials

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Previous Post: « JSTL Format fmt:formatNumber Tag
Next Post: JSTL Formating fmt:timeZone Tag »

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact