public static void main(String[] args) {
int maxLength =7;
double num1=18.3;
String num =String.valueOf(num1);
StringBuffer sb = new StringBuffer(num);
if (num.length()<maxLength){
for (int i=0;i<maxLength-num.length();i++){
// 第一位开始加0
sb.insert(0,“0”);
sb.append(9); //追加
}
System.out.println(sb);
}else {
System.out.println(num);
}
}