Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there an simple way of printing this 1

Status
Not open for further replies.

xwb

Programmer
Jul 11, 2002
6,828
GB
I've got a version number out of a package. It is given in the form 12345678. This is supposed to represent version 12.34.56.78 of the package. I'm just wondering whether there is a simple way of printing this in Java. So far the only thing I can come up with is
Code:
ver = 12345678;
v4 = ver % 100;
ver /= 100;
v3 = ver  % 100;
ver /= 100;
v2 = ver % 100;
v1 = ver / 100;
System.out.printf ("%d.%d.%d.%d\n", v1, v2, v3, v4);
 
Try this:

Code:
int i = 12345678;
DecimalFormat formattter = new DecimalFormat("##,##,##,##");
System.out.println (formatter.format (i));

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top