Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7428751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:51:18+00:00 2026-05-29T08:51:18+00:00

I would like to format a number in JSTL in ways it will look

  • 0

I would like to format a number in JSTL in ways it will look like:

<c:set var="num" value="12345678000199"/>
<fmt:formatNumber type="number" value="${num}" pattern=?/>
<!-- desired output: 12.345.678/0001-99 (Brazilian CNPJ [companies' IRS ID])-->

Thanks in advance!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:51:19+00:00Added an answer on May 29, 2026 at 8:51 am

    That’s not possible with standard JSTL tags nor with the standard NumberFormat API which it is using under the covers. You’d need to create a custom JSP tag or EL function for that. You could achieve the job with simple String manipulation methods or even (ab)use Swing’s MaskFormatter:

    String cnpj = "12345678000199";
    MaskFormatter mf = new MaskFormatter("##.###.###/####-##");
    mf.setValueContainsLiteralCharacters(false);
    System.out.println(mf.valueToString(cnpj)); // 12.345.678/0001-99
    

    With an EL function you can ultimately end up like this:

    <c:out value="${util:formatCnpj(user.cnpj)}" />
    

    For more detail on creating an EL function, see also the bottom of Hidden features of JSP/Servlet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to format number displayed by <s:property value=summary.total/> tag in Struts 2.
I would like to format a float number as a percent-value with JFormattedTextField that
I would like to set some initial variables (like format compact and the current
i would like to set the date format of all the dates in my
I'm trying to format this and other elements alike, so it would look like
I would like to format some double values to a specific number of digits
I would like to format a number to display 00 instead of 0 ,
I have a product number which I would like to format using a mask.
I would like to have a TextBox that displays a number in currency format
I would like to display the a number value to the max number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.