Date date = new Date(); int number = 1; for (X x :x) {String no = String.format("ZG" + sf.format(date) + "%05d", number); number++; System.out.println("生成的编号:" + no);//ZG2023042400001 }