public class OrderIDGenerator {
private String orderID;
static private int no=1;
public synchronized String getOrderID() {
SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyyMMdd");
orderID = sDateFormat.format(new java.util.Date());
String strNum=String.format("%06d", no);
System.out.println(orderID+strNum);
no++;
return orderID;
}
Java时间处理和int字符串补0问题
最新推荐文章于 2025-05-02 14:30:00 发布