public class TestAutoSelfPK {
static String getPK(Date dt,int id){
id++;
SimpleDateFormat df=new SimpleDateFormat(“yyyyMMdd”);
String dtString=df.format(dt);
// Log.getLog().info(“dtString=”+dtString);
DecimalFormat dcf=new DecimalFormat(“‘”+dtString+”-‘000″);
String value=dcf.format(id);
return value;
}
public static void main(String[] args) {
// Date dt=new Date(117,4,16);
Date dt=new Date(); //当前日期
int id=145;
String myid=getPK(dt, id);
Log.getLog().info(“myid=”+myid);
}
}