Re: Java number format question....please help

2001-11-30 Thread Dmitry Namiot

Why do not use DecimalFormat?
See for example Number custom tag on
http://www.servletsuite.com/jsp.htm

Hi all,

How do I format a integer 20 to 00020 ?

Thanks.

Regards,
KL OOI

--
Coldbeans Software - server-side Java (tm) components
http://www.servletsuite.com



__
Your favorite stores, helpful shopping tools and great gift ideas. Experience the 
convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Re: Java number format question....please help

2001-11-29 Thread David T. Wilson

KL,

Assuming you just want to display the 20 as 00020 then you could do some
formatting like:

public class TestNum
{
 public static void main(String[] args)
 {
 int x = 20;
 String numberString = new String();


 System.out.println(Option One:);
 System.out.println(000 + x);
 System.out.println();
 System.out.println();

 //if you want the output to always be 5 long!
 System.out.println(Option Two:);

 for(int i = 0;i  (5 - (Integer.toString(x).length())) ; i++)
 numberString = numberString + 0;

 numberString = numberString + Integer.toString(x);

 System.out.println(numberString);

 }
}

Hope this helps.  I am also interested if there is a better way to do this
because I am just learning Java my self.

Have fun.

David T. Wilson





At 10:28 AM 11/30/2001 +0800, KL OOI wrote:
Hi all,

How do I format a integer 20 to 00020 ?

Thanks.

Regards,
KL OOI



_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff
JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

  http://archives.java.sun.com/jsp-interest.html
  http://java.sun.com/products/jsp/faq.html
  http://www.esperanto.org.nz/jsp/jspfaq.jsp
  http://www.jguru.com/faq/index.jsp
  http://www.jspinsider.com

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com