Project

General

Profile

« Previous | Next » 

Revision 6051

Added by rnahf over 13 years ago

zero padded date string in DocumentUtil.generateDocumentId() for readability

View differences:

src/edu/ucsb/nceas/metacat/util/DocumentUtil.java
535 535
        Calendar calendar = new GregorianCalendar(pdt);
536 536
        Date trialTime = new Date();
537 537
        calendar.setTime(trialTime);
538
        docid.append(calendar.get(Calendar.YEAR));
539
        docid.append(calendar.get(Calendar.DAY_OF_YEAR));
540
        docid.append(calendar.get(Calendar.HOUR_OF_DAY));
541
        docid.append(calendar.get(Calendar.MINUTE));
542
        docid.append(calendar.get(Calendar.SECOND));
543
        docid.append(calendar.get(Calendar.MILLISECOND));
544

  
538
        // using yyyymmddhhmmssmmm by convention (zero padding to preserve places)
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
				)
549
        );
545 550
        if (revision > 0) {
546 551
            docid.append(".").append(revision);
547 552
        }

Also available in: Unified diff