Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old June 21st, 2001, 06:24 AM
daisydook daisydook is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 3 daisydook User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How to covert a 2 digit number to a 4 digit number?

Hi all,

Anyone know what to use to convert an 2 digit integer e.g. 93, to a 4-digit integer e.g. 0093?

Thanks :-)

Reply With Quote
  #2  
Old June 21st, 2001, 09:10 AM
bigtrick bigtrick is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: chicago, il
Posts: 9 bigtrick User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
convert 93 to an Integer, then concatenate it with 00, then convert back to a string. note, you can't keep "0093" in an int or a float as it will truncate the extra zeroes.


so,

int a = 93;
Integer b= new Integer(a);
StringBuffer c = new StringBuffer("00" + b.toString());
string d = c.toString();


this would be a wordy way of doing it, but it illustrates what needs to be done.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > How to covert a 2 digit number to a 4 digit number?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway