|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 :-) |
|
#2
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > How to covert a 2 digit number to a 4 digit number? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|