Join us on Facebook

Please wait..10 Seconds Cancel

1.03.2014

// // Leave a Comment

Demostration Of Format Tag In Java

Format Tag

Format_Tags.jsp

 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 
<html> 
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
        <title>Format Tags</title> 
    </head> 
    <body> 
         
<c:set var="balance" value="120000.2309" /> 
<h3>Number Format:</h3>  
<b>Original Number : </b> ${balance} 
<p><b>Number_Format (Currency):</b> <fmt:formatNumber value="${balance}"  
            type="currency"/></p> 
<p><b>Number_Format (Max 3 Integers):</b> <fmt:formatNumber type="number"  
            maxIntegerDigits="3" value="${balance}" /></p> 
<p><b>Number_Format (Max 3 Decimals): </b><fmt:formatNumber type="number"  
            maxFractionDigits="3" value="${balance}" /></p> 
 
<br/> 
<br/> 
<br/> 
        <h3> Number Parse:</h3>         
<c:set var="balance" value="12345.89" /> 
<fmt:parseNumber var="i" type="number" value="${balance}" /> 
<p><b>Parsed_Number (Whole Number) : </b><c:out value="${i}" /></p> 
<fmt:parseNumber var="i" integerOnly="true"  
                       type="number" value="${balance}" /> 
<p><b>Parsed_Number (Integer Part Only) : </b><c:out value="${i}" /></p> 
    </body> 
</html> 

0 comments:

Post a Comment