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问题
最新推荐文章于 2023-04-04 09:14:26 发布