08-format integer data into a string of the specified length (string processing)

Source: Internet
Author: User

Stringutil. Java

Package COM. LH. bean; import Java. text. numberformat; public class stringutil {// defines the private int intvalue of the integer to be formatted; // The formatted string private string formatstr; // the minimum number of digits of the formatted string private int minimumdigit; // default constringutil () {} public int getminimumdigit () {return minimumdigit;} public void setminimumdigit (INT minimumdigit) {This. minimumdigit = minimumdigit;} public int getintvalue () {return intvalue;} public void setintvalue (INT intvalue) {This. intvalue = intvalue;} Public String getformatstr () {// obtain the numberformat NF = numberformat, a regular value format object. getinstance (); // sets the minimum number of bits in the integer part of the formatted number. setminimumintegerdigits (minimumdigit); // return the formatted string and replace "," with return NF. format (intvalue ). replace (",", "");} public void setformatstr (string formatstr) {This. formatstr = formatstr ;}}

 

Index. jsp

<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" UTF-8 "%> <HTML> 

Format. jsp

<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" UTF-8 "%> <HTML> 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.