publicclassUUID{ //机器码 privatestaticfinal String machineNum = SysSetting.sys_machineNum; /** The FieldPosition. */ privatestaticfinal FieldPosition HELPER_POSITION = new FieldPosition(0); /** This Format for format the data to special format. */ privatefinalstatic Format dateFormat = new SimpleDateFormat("yyMMddHHmmssS"); /** This Format for format the number to special format. */ privatefinalstatic NumberFormat numberFormat = new DecimalFormat("00"); /** This int is the sequence number ,the default value is 0. */ privatestaticint seq = 0; privatestaticfinalint MAX = 99; /** * 时间格式生成序列 * @return String */ publicstaticsynchronized String generateSequenceNo(){ Calendar rightNow = Calendar.getInstance(); StringBuffer sb = new StringBuffer(); dateFormat.format(rightNow.getTime(), sb, HELPER_POSITION); numberFormat.format(seq, sb, HELPER_POSITION); if (seq == MAX) { seq = 0; } else { seq++; } return machineNum + sb.toString(); } }