• Post Reply Bookmark Topic Watch Topic
  • New Topic

5 digit integers ...  RSS feed

 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a case in which i want my integers be 5 digitized, ex: 00001, 00011, 00100 bla bla bla.

Is there an API that re formats my integers automatically based on this format after increasing the value of the integer or i have to do it myself ?

Please advice ...

Kind regards,
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on how you are viewing the contents of the int variables.
If as Strings, you could easily use substring to get an output of 5 characters by concatenating the int after some 0s: "0000"+int-value and picking off the last 5 characters.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or use java.text.DecimalFormat, or String.format
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!