第一种: Date date = new Date(); int year = date.getYear() + 1900; int month = date.getMonth() + 1; //int month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1; String moo = null; if (month < 10) { moo = 0 + "" + month; } else { moo = month + ""; } int day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(); String result = year + "" + moo + "" + day + "";
第二种
Date date = new Date(); String str = date.toString().replaceAll("[[\\s-:punct:]]",""); data.put("subscibeid", replaceAll + result + countApply);
结果第二中长度比较长