写廖很丑的一个
NumberFormat formatter = new DecimalFormat("000"); String s = formatter.format(23);
String s1 = formatter.format(5);
System.out.println("s==" + s);
System.out.println("s1=" + s1);
NumberFormat formatter = new DecimalFormat("000"); String s = formatter.format(23);
String s1 = formatter.format(5);
System.out.println("s==" + s);
System.out.println("s1=" + s1);
String cid = "58693";
int len = 7-cid.length();
System.out.println("cidl:"+cid.length());
if(cid.length()<7)
{
for (int i=0;i<len;i++)
{
cid ="0"+cid;
}
}
System.out.println("cid:"+cid);
一般自己写!比较简单!
String cid = "58693";
int len = 7-cid.length();
System.out.println("cidl:"+cid.length());
if(cid.length()<7)
{
for (int i=0;i<len;i++)
{
cid ="0"+cid;
}
}
System.out.println("cid:"+cid);
------------------------------------如果前面加三个“0”,成了 0005 00023
然后取后面三位 005 023
这样也行吧