Revision 6743
Added by Chris Jones about 13 years ago
src/edu/ucsb/nceas/metacat/util/DocumentUtil.java | ||
---|---|---|
537 | 537 |
calendar.setTime(trialTime); |
538 | 538 |
// using yyyymmddhhmmssmmm by convention (zero padding to preserve places) |
539 | 539 |
// will help with looking at logs and especially database tables. |
540 |
docid.append(String.format("%04d%02d%02d%02d%02d%02d%03d", |
|
541 |
calendar.get(Calendar.YEAR), |
|
542 |
calendar.get(Calendar.MONTH) + 1, // adjust 0-11 range to 1-12 |
|
543 |
calendar.get(Calendar.DAY_OF_MONTH), |
|
544 |
calendar.get(Calendar.HOUR_OF_DAY), |
|
545 |
calendar.get(Calendar.MINUTE), |
|
546 |
calendar.get(Calendar.SECOND), |
|
547 |
calendar.get(Calendar.MILLISECOND) |
|
548 |
) |
|
540 |
String randomStr = (new Double(Math.random())).toString(); |
|
541 |
randomStr = randomStr.substring(randomStr.length() - 5); // last 5 characters |
|
542 |
docid.append(String.format("%04d%02d%02d%02d%02d%02d%03d%s", |
|
543 |
calendar.get(Calendar.YEAR), |
|
544 |
calendar.get(Calendar.MONTH) + 1, // adjust 0-11 range to 1-12 |
|
545 |
calendar.get(Calendar.DAY_OF_MONTH), |
|
546 |
calendar.get(Calendar.HOUR_OF_DAY), |
|
547 |
calendar.get(Calendar.MINUTE), |
|
548 |
calendar.get(Calendar.SECOND), |
|
549 |
calendar.get(Calendar.MILLISECOND), |
|
550 |
randomStr) |
|
549 | 551 |
); |
550 | 552 |
if (revision > 0) { |
551 | 553 |
docid.append(".").append(revision); |
Also available in: Unified diff
To avoid id generation conflicts happening at the same millisecond, append a 5 character random string to the end of the docid.