DecimalFormat df10 = new DecimalFormat("0000000000");It takes an int, format it into a String padded with zeroes on the left, then strip away the first 4 characters. Then of course we turn it back into an int.
String idStr = df10.format(peer.execid);
idStr = idStr.substring(4);
exec.execId = Integer.parseInt(idStr);
Knowing that the id is always positive, this code is completely equivalent to that one:
exec.execId = peer.execId % 1000000;
No comments:
Post a Comment