Example usage for java.util GregorianCalendar before

List of usage examples for java.util GregorianCalendar before

Introduction

In this page you can find the example usage for java.util GregorianCalendar before.

Prototype

public boolean before(Object when) 

Source Link

Document

Returns whether this Calendar represents a time before the time represented by the specified Object.

Usage

From source file:TimePeriod.java

/**
 * Gibt zurck, wie oft der bergebene Wochentag im Zeitraum vorkommt.
 * /*ww  w  . j  av a 2s.c o m*/
 * @param wochentag
 *            Sonntag = 1
 * @return
 */
public int getNumberOfWeekdays(int wochentag) {
    int ergebnis = 0;
    GregorianCalendar temp = new GregorianCalendar();
    temp.setTime(from.getTime());
    // Schleife ber alle Tage
    int aktuellerTag;
    while (temp.before(to)) {
        aktuellerTag = temp.get(Calendar.DAY_OF_WEEK);
        if (aktuellerTag == wochentag)
            ergebnis++;
        temp.setTimeInMillis(temp.getTimeInMillis() + ONE_DAY);
    }
    return ergebnis;
}

From source file:org.awknet.commons.model.business.UserBOImpl.java

/**
 * Verify if a retrieve code still valid. The default time validation is 2
 * days.//from  w  w w.j a v a 2  s.c  o  m
 * 
 * @param requestDate
 * @return true for if is valid.
 */
public boolean isValidRequest(Date requestDate, final String retrieveCode) throws RetrieveCodeException {

    RetrievePasswordLog rpLog = daoFactory.getRetrievePasswordLogDao().findRetrieveCode(retrieveCode);
    if (rpLog == null)
        throw new RetrieveCodeException(RetrieveCodeExceptionType.RETRIEVE_CODE);

    if (rpLog.getUpdated())
        throw new RetrieveCodeException(RetrieveCodeExceptionType.RETRIEVE_CODE);

    LOG.debug("[VALID REQUEST] found something!");
    // int
    // days=SystemMessageAcessor.getPropertyAsInteger("request.activation.form.valid.until.days");

    int days = RetrievePasswordLog.DEFAULT_TIME_RETRIEVE_CODE;

    GregorianCalendar currentDate = new GregorianCalendar();
    GregorianCalendar dateGenerateLink = new GregorianCalendar();
    dateGenerateLink.setTime(requestDate);
    dateGenerateLink.add(Calendar.DAY_OF_YEAR, days);

    if (currentDate.before(dateGenerateLink)) {
        return true;
        // try {
        // FIXME must set true here?
        // rpLog.setUpdated(true);
        // daoFactory.beginTransaction();
        // daoFactory.getRetrievePasswordLogDao().update(rpLog);
        // daoFactory.commit();
        // return true;
        // } catch (ConstraintViolationException e) {
        // // FIXME adjust message
        // LOG.error("[VALID REQUEST] code not updated in DB.", e);
        // return false;
        // } catch (Exception e) {
        // LOG.error("[VALID REQUEST] generic error in DB.", e);
        // return false;
        // }
    }

    return false;
}

From source file:org.agnitas.util.AgnUtils.java

/**
 * Checks if date is in future./*from  w  w w.j a v  a2s.  c o m*/
 *
 * @param aDate Checked date.
 */
public static boolean isDateInFuture(Date aDate) {
    boolean result = false;
    GregorianCalendar aktCal = new GregorianCalendar();
    GregorianCalendar tmpCal = new GregorianCalendar();

    tmpCal.setTime(aDate);
    aktCal.add(GregorianCalendar.MINUTE, 5); // look five minutes in future ;-)
    if (aktCal.before(tmpCal)) {
        result = true;
    }

    return result;
}

From source file:com.activiti.android.ui.fragments.task.TaskDetailsFoundationFragment.java

private void displayDueDate(Date due) {
    dueDateHolder.topText.setText(R.string.task_field_due);
    dueDateHolder.icon.setImageResource(R.drawable.ic_event_grey);

    dueAt = due;/*w  w w  .ja v  a2s .c o m*/
    if (due != null) {
        StringBuilder builder = new StringBuilder();
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(due);
        if (calendar.before(new GregorianCalendar())) {
            builder.append("<font color='#F44336'>");
            builder.append(DateFormat.getLongDateFormat(getActivity()).format(due.getTime()));
            builder.append("</font>");
        } else {
            builder.append(DateFormat.getLongDateFormat(getActivity()).format(due.getTime()));
        }
        dueDateHolder.bottomText.setText(builder.toString());
        dueDateHolder.bottomText.setText(Html.fromHtml(builder.toString()), TextView.BufferType.SPANNABLE);
    } else {
        dueDateHolder.bottomText.setText(R.string.task_message_no_duedate);
    }
    if (!isEnded) {
        viewById(R.id.task_details_due_container).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DatePickerFragment.newInstance(DUE_DATE, getTag()).show(getFragmentManager(),
                        DatePickerFragment.TAG);
            }
        });
    } else {
        UIUtils.setBackground(viewById(R.id.task_details_due_container), null);
    }
}

From source file:edu.stanford.muse.index.IndexUtils.java

public static List<MultiDoc> partitionDocsByInterval(Collection<? extends DatedDocument> allDocs,
        boolean monthsNotYears) {
    List<MultiDoc> result = new ArrayList<MultiDoc>();
    if (allDocs.size() == 0)
        return result;

    Pair<Date, Date> p = EmailUtils.getFirstLast(allDocs);
    Date first = p.getFirst();//from w  w  w  .  j a  va 2s .c o  m
    Date last = p.getSecond();

    // compute the monthly intervals
    List<Date> intervals;
    if (monthsNotYears)
        intervals = Util.getMonthlyIntervals(first, last);
    else
        intervals = Util.getYearlyIntervals(first, last);

    int nIntervals = intervals.size() - 1;
    for (int i = 0; i < nIntervals; i++) {
        String clusterDescription;
        Date d = intervals.get(i);
        GregorianCalendar c = new GregorianCalendar();
        c.setTime(d);

        if (!monthsNotYears)
            clusterDescription = Integer.toString(c.get(Calendar.YEAR));
        else
            clusterDescription = CalendarUtil.getDisplayMonth(c) + " " + c.get(Calendar.YEAR);

        result.add(new MultiDoc(i, clusterDescription));
    }

    for (DatedDocument ed : allDocs) {
        // find which interval this email belongs to
        int selectedInterval = -1;
        // TODO: if all this API does is either partition by month or year then no need to "search".
        Date c = ed.date;
        for (int i = 0; i < nIntervals; i++) {
            Date intervalStart = intervals.get(i);
            Date intervalEnd = intervals.get(i + 1);
            if (!c.before(intervalStart) && c.before(intervalEnd)) {
                selectedInterval = i;
                break;
            }
        }

        // this doc goes into interval # selectedInterval
        MultiDoc whichList = result.get(selectedInterval);
        whichList.add(ed);
    }

    return result;
}

From source file:org.motechproject.mobile.omp.manager.intellivr.IntellIVRBean.java

/**
 * Method to request a {@link RequestType} instance based on the content of the 
 * {@link IVRCallSession} instance and the provided externalId
 * @param session//from  w  w w .  j a v a2 s . c o  m
 * @param externalId
 * @return
 */
public RequestType createIVRRequest(IVRCallSession session, String externalId) {

    Set<MessageRequest> messageRequests = session.getMessageRequests();

    log.debug("Creating IVR Request for " + messageRequests);

    RequestType ivrRequest = new RequestType();

    /*
     * These first three values are fixed
     */
    ivrRequest.setApiId(apiID);
    ivrRequest.setMethod(method);
    ivrRequest.setReportUrl(reportURL);

    /*
     * recipient's phone number
     */
    ivrRequest.setCallee(session.getPhone());

    /*
     * Set language
     */
    String language = session.getLanguage();
    ivrRequest.setLanguage(language != null ? language : defaultLanguage);

    /*
     * Private id
     */
    ivrRequest.setPrivate(externalId);

    /*
     * Create the content
     */
    MessageRequest infoRequest = null;
    List<String> reminderMessages = new ArrayList<String>();
    for (MessageRequest messageRequest : messageRequests) {

        long notificationId = messageRequest.getNotificationType().getId();

        if (!ivrNotificationMap.containsKey(notificationId)) {
            log.debug("No IVR Notification mapping found for " + notificationId);
        } else {

            IVRNotificationMapping mapping = ivrNotificationMap.get(notificationId);

            if (mapping.getType().equalsIgnoreCase(IVRNotificationMapping.INFORMATIONAL)) {
                if (infoRequest == null)
                    infoRequest = messageRequest;
                else {
                    GregorianCalendar currDateFrom = new GregorianCalendar();
                    currDateFrom.setTime(infoRequest.getDateFrom());
                    GregorianCalendar possibleDateFrom = new GregorianCalendar();
                    possibleDateFrom.setTime(messageRequest.getDateFrom());
                    if (currDateFrom.before(possibleDateFrom))
                        infoRequest = messageRequest;
                }

            } else {
                reminderMessages.add(mapping.getIvrEntityName());
            }

        }

    }

    if (infoRequest != null) {
        IVRNotificationMapping infoMapping = ivrNotificationMap.get(infoRequest.getNotificationType().getId());
        ivrRequest.setTree(infoMapping.getIvrEntityName());
    }

    RequestType.Vxml vxml = new RequestType.Vxml();
    vxml.setPrompt(new RequestType.Vxml.Prompt());

    /*
     * add a break element if the preReminderDelay is > 0
     */
    if (preReminderDelay > 0) {
        BreakType breakType = new BreakType();
        breakType.setTime(Integer.toString(preReminderDelay) + "s");
        vxml.getPrompt().getAudioOrBreak().add(breakType);
    }

    /*
     * add a welcome message if an outbound call and a recording name has been configured
     */
    if (session.getCallDirection().equalsIgnoreCase(IVRCallSession.OUTBOUND)
            && welcomeMessageRecordingName != null && welcomeMessageRecordingName.trim().length() > 0) {
        AudioType welcome = new AudioType();
        welcome.setSrc(welcomeMessageRecordingName);
        vxml.getPrompt().getAudioOrBreak().add(welcome);
    }

    /*
     * add the reminder messages
     */
    for (String fileName : reminderMessages) {
        AudioType audio = new AudioType();
        audio.setSrc(fileName);
        vxml.getPrompt().getAudioOrBreak().add(audio);
    }
    ivrRequest.setVxml(vxml);

    return ivrRequest;

}

From source file:eu.europa.ec.markt.tlmanager.core.validation.Validation.java

/**
 * If Nextupdate is not empty, the difference between IssuedDate and NextUpdate cannot exceed 6 months.
 *///from w  w w  .j  ava 2  s .  c o m
private void checkRuleNextUpdate() {
    NextUpdateType nextUpdate = schemeInformation.getNextUpdate();
    String nuName = QNames._NextUpdate_QNAME.getLocalPart(), liName = QNames._ListIssueDateTime;
    if (nextUpdate != null && nextUpdate.getDateTime() != null) {
        GregorianCalendar nextUpdateTime = nextUpdate.getDateTime().toGregorianCalendar();
        GregorianCalendar listIssueTime = schemeInformation.getListIssueDateTime().toGregorianCalendar();
        if (nextUpdateTime.before(listIssueTime)) {
            logger.error(nuName + uiKeys.getString("Validation.rule.nextUpdate.mustBeLater") + liName + "!",
                    tsl);
        } else {
            GregorianCalendar gc = (GregorianCalendar) listIssueTime.clone();
            gc.add(Calendar.MONTH, 6);
            if (gc.before(nextUpdateTime)) {
                logger.error(uiKeys.getString("Validation.rule.nextUpdate.dontExceed6Months") + liName + " - "
                        + nuName + "!", tsl);
            }
        }
    }
}

From source file:com.bt.heliniumstudentapp.ScheduleFragment.java

@SuppressWarnings("ConstantConditions")
@Override//from   ww w .  jav  a  2 s . co  m
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState) {
    mainContext = (AppCompatActivity) getActivity();
    scheduleLayout = inflater.inflate(R.layout.fragment_schedule, viewGroup, false);

    MainActivity.setToolbarTitle(mainContext, getResources().getString(R.string.schedule), null);

    weekDaysLV = (ListView) scheduleLayout.findViewById(R.id.lv_weekDays_fs);

    final boolean restart = PreferenceManager.getDefaultSharedPreferences(mainContext)
            .getBoolean("forced_restart", false);

    if (restart)
        PreferenceManager.getDefaultSharedPreferences(mainContext).edit().putBoolean("forced_restart", false)
                .apply();

    if (restart) { //TODO Database check?
        MainActivity.setStatusBar(mainContext);

        scheduleFocus = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.WEEK_OF_YEAR);

        scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_0", null);

        if (MainActivity.isOnline())
            parseData(HeliniumStudentApp.ACTION_ONLINE);
        else
            parseData(HeliniumStudentApp.ACTION_OFFLINE);
    } else if (scheduleJson == null) {
        final boolean online = MainActivity.isOnline();

        scheduleFocus = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.WEEK_OF_YEAR);

        if (online && PreferenceManager.getDefaultSharedPreferences(mainContext)
                .getBoolean("pref_updates_auto_update", true)) {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
                new UpdateClass(mainContext, false).execute();
            else
                new UpdateClass(mainContext, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }

        if (online && (PreferenceManager.getDefaultSharedPreferences(mainContext)
                .getBoolean("pref_schedule_init", true)
                || PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_0",
                        null) == null)) {
            getSchedule(HeliniumStudentApp.DIREC_CURRENT, HeliniumStudentApp.ACTION_INIT_IN);
        } else if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) {
            MainActivity.setStatusBar(mainContext);

            scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_0",
                    null);

            if (online)
                parseData(HeliniumStudentApp.ACTION_ONLINE);
            else
                parseData(HeliniumStudentApp.ACTION_OFFLINE);
        }
    }

    ((SwipeRefreshLayout) scheduleLayout).setColorSchemeResources(MainActivity.accentSecondaryColor,
            MainActivity.accentPrimaryColor, MainActivity.primaryColor);
    ((SwipeRefreshLayout) scheduleLayout).setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            refresh();
        }
    });

    MainActivity.prevIV.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) {
                if (MainActivity.isOnline()) {
                    scheduleFocus--;

                    getSchedule(HeliniumStudentApp.DIREC_BACK, HeliniumStudentApp.ACTION_REFRESH_IN);
                } else {
                    final int currentWeek = new GregorianCalendar(HeliniumStudentApp.LOCALE)
                            .get(Calendar.WEEK_OF_YEAR);

                    if (scheduleFocus > currentWeek + 1) {
                        scheduleFocus = currentWeek + 1;
                        scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext)
                                .getString("schedule_1", null);
                    } else {
                        scheduleFocus = currentWeek;
                        scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext)
                                .getString("schedule_0", null);
                    }

                    parseData(HeliniumStudentApp.ACTION_OFFLINE);
                }
            }
        }
    });

    MainActivity.historyIV.setOnClickListener(new OnClickListener() { //FIXME Huge mess
        private int year;
        private int monthOfYear;
        private int dayOfMonth;

        @Override
        public void onClick(View v) {
            if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) {
                if (MainActivity.isOnline()) {
                    MainActivity.setUI(HeliniumStudentApp.VIEW_SCHEDULE, HeliniumStudentApp.ACTION_ONLINE);

                    final AlertDialog.Builder weekpickerDialogBuilder = new AlertDialog.Builder(
                            new ContextThemeWrapper(mainContext, MainActivity.themeDialog));

                    final View view = View.inflate(mainContext, R.layout.dialog_schedule, null);
                    weekpickerDialogBuilder.setView(view);

                    final DatePicker datePicker = (DatePicker) view.findViewById(R.id.np_weekpicker_dw);

                    year = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.YEAR);
                    monthOfYear = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.MONTH);
                    dayOfMonth = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.DAY_OF_MONTH);

                    weekpickerDialogBuilder.setTitle(getString(R.string.go_to));

                    weekpickerDialogBuilder.setPositiveButton(getString(android.R.string.ok),
                            new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    final GregorianCalendar date = new GregorianCalendar(
                                            HeliniumStudentApp.LOCALE);
                                    final GregorianCalendar today = new GregorianCalendar(
                                            HeliniumStudentApp.LOCALE);

                                    date.set(Calendar.YEAR, year);
                                    date.set(Calendar.MONTH, monthOfYear);
                                    date.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                                    date.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
                                    today.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);

                                    scheduleFocus = (today.get(Calendar.WEEK_OF_YEAR))
                                            - ((int) ((today.getTimeInMillis() / (1000 * 60 * 60 * 24 * 7))
                                                    - (date.getTimeInMillis() / (1000 * 60 * 60 * 24 * 7))));

                                    getSchedule(HeliniumStudentApp.DIREC_OTHER,
                                            HeliniumStudentApp.ACTION_REFRESH_IN);
                                }
                            });

                    weekpickerDialogBuilder.setNegativeButton(getString(android.R.string.cancel), null);

                    final AlertDialog weekPickerDialog = weekpickerDialogBuilder.create();

                    final GregorianCalendar minDate = new GregorianCalendar(HeliniumStudentApp.LOCALE);
                    minDate.set(Calendar.YEAR, 2000);
                    minDate.set(Calendar.WEEK_OF_YEAR, 1);

                    final GregorianCalendar maxDate = new GregorianCalendar(HeliniumStudentApp.LOCALE);
                    maxDate.set(Calendar.YEAR, 2038);
                    maxDate.set(Calendar.WEEK_OF_YEAR, 1);

                    datePicker.init(year, monthOfYear, dayOfMonth, new DatePicker.OnDateChangedListener() {
                        final GregorianCalendar newDate = new GregorianCalendar(HeliniumStudentApp.LOCALE);

                        @Override
                        public void onDateChanged(DatePicker view, int dialogYear, int dialogMonthOfYear,
                                int dialogDayOfMonth) {
                            newDate.set(year, monthOfYear, dayOfMonth);

                            year = dialogYear;
                            monthOfYear = dialogMonthOfYear;
                            dayOfMonth = dialogDayOfMonth;

                            if (minDate != null && minDate.after(newDate))
                                view.init(minDate.get(Calendar.YEAR), minDate.get(Calendar.MONTH),
                                        minDate.get(Calendar.DAY_OF_MONTH), this);
                            else if (maxDate != null && maxDate.before(newDate))
                                view.init(maxDate.get(Calendar.YEAR), maxDate.get(Calendar.MONTH),
                                        maxDate.get(Calendar.DAY_OF_MONTH), this);
                            else
                                view.init(year, monthOfYear, dayOfMonth, this);
                        }
                    });

                    weekPickerDialog.setCanceledOnTouchOutside(true);
                    weekPickerDialog.show();

                    weekPickerDialog.getButton(AlertDialog.BUTTON_POSITIVE)
                            .setTextColor(getColor(mainContext, MainActivity.accentSecondaryColor));
                    weekPickerDialog.getButton(AlertDialog.BUTTON_NEGATIVE)
                            .setTextColor(getColor(mainContext, MainActivity.accentSecondaryColor));
                } else {
                    scheduleFocus = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.WEEK_OF_YEAR);
                    scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext)
                            .getString("schedule_0", null);

                    parseData(HeliniumStudentApp.ACTION_OFFLINE);
                }
            }
        }
    });

    MainActivity.nextIV.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) {
                if (MainActivity.isOnline()) {
                    scheduleFocus++;

                    getSchedule(HeliniumStudentApp.DIREC_NEXT, HeliniumStudentApp.ACTION_REFRESH_IN);
                } else {
                    final int currentWeek = new GregorianCalendar(HeliniumStudentApp.LOCALE)
                            .get(Calendar.WEEK_OF_YEAR);

                    if (PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_1",
                            null) != null && scheduleFocus >= currentWeek) {
                        scheduleFocus = currentWeek + 1;
                        scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext)
                                .getString("schedule_1", null);
                    } else {
                        scheduleFocus = currentWeek;
                        scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext)
                                .getString("schedule_0", null);
                    }

                    parseData(HeliniumStudentApp.ACTION_OFFLINE);
                }
            }
        }
    });

    return scheduleLayout;
}

From source file:org.alfresco.rest.api.tests.TestCMIS.java

/**
 * MNT-12680 /* w w  w.  j  a va2s  . co m*/
 * The creation date of version should be the same as creation date of the original node
 * @throws Exception
 */
@Test
public void testCreationDate() throws Exception {
    // create a site
    final TestNetwork network1 = getTestFixture().getRandomNetwork();
    String username = "user" + System.currentTimeMillis();
    PersonInfo personInfo = new PersonInfo(username, username, username, "password", null, null, null, null,
            null, null, null);
    TestPerson person1 = network1.createUser(personInfo);
    String person1Id = person1.getId();

    final String siteName = "site" + System.currentTimeMillis();

    TenantUtil.runAsUserTenant(new TenantRunAsWork<NodeRef>() {

        @Override
        public NodeRef doWork() throws Exception {
            SiteInformation siteInfo = new SiteInformation(siteName, siteName, siteName, SiteVisibility.PUBLIC);
            final TestSite site = network1.createSite(siteInfo);
            final NodeRef resNode = repoService.createDocument(site.getContainerNodeRef("documentLibrary"),
                    "testdoc.txt", "Test Doc1 Title", "Test Doc1 Description", "Test Content");
            return resNode;
        }
    }, person1Id, network1.getId());

    // create a document
    publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
    CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, CMIS_VERSION_10,
            AlfrescoObjectFactoryImpl.class.getName());
    AlfrescoFolder docLibrary = (AlfrescoFolder) cmisSession
            .getObjectByPath("/Sites/" + siteName + "/documentLibrary");
    Map<String, String> properties = new HashMap<String, String>();
    {
        properties.put(PropertyIds.OBJECT_TYPE_ID, TYPE_CMIS_DOCUMENT);
        properties.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt");
    }
    ContentStreamImpl fileContent = new ContentStreamImpl();
    {
        ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(GUID.generate(), ".txt"));
        writer.putContent("some content");
        ContentReader reader = writer.getReader();
        fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
        fileContent.setStream(reader.getContentInputStream());
    }

    Document autoVersionedDoc = docLibrary.createDocument(properties, fileContent, VersioningState.MAJOR);
    String objectId = autoVersionedDoc.getId();
    String bareObjectId = getBareObjectId(objectId);
    // create versions
    for (int i = 0; i < 3; i++) {
        Document doc1 = (Document) cmisSession.getObject(bareObjectId);

        ObjectId pwcId = doc1.checkOut();
        Document pwc = (Document) cmisSession.getObject(pwcId.getId());

        ContentStreamImpl contentStream = new ContentStreamImpl();
        {
            ContentWriter writer = new FileContentWriter(
                    TempFileProvider.createTempFile(GUID.generate(), ".txt"));
            writer.putContent(GUID.generate());
            ContentReader reader = writer.getReader();
            contentStream.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
            contentStream.setStream(reader.getContentInputStream());
        }
        pwc.checkIn(true, Collections.EMPTY_MAP, contentStream, "checkin " + i);
    }

    GregorianCalendar cDateFirst = cmisSession.getAllVersions(bareObjectId).get(0).getCreationDate();
    GregorianCalendar cDateSecond = cmisSession.getAllVersions(bareObjectId).get(2).getCreationDate();

    if (cDateFirst.before(cDateSecond) || cDateFirst.after(cDateSecond)) {
        fail("The creation date of version should be the same as creation date of the original node");
    }
}