Example usage for com.liferay.portal.util PropsValues INDEX_DATE_FORMAT_PATTERN

List of usage examples for com.liferay.portal.util PropsValues INDEX_DATE_FORMAT_PATTERN

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsValues INDEX_DATE_FORMAT_PATTERN.

Prototype

String INDEX_DATE_FORMAT_PATTERN

To view the source code for com.liferay.portal.util PropsValues INDEX_DATE_FORMAT_PATTERN.

Click Source Link

Usage

From source file:com.liferay.asset.test.util.BaseAssetSearchTestCase.java

License:Open Source License

protected void testOrderByExpirationDate(final AssetEntryQuery assetEntryQuery, final String orderByType,
        final Date[] expirationDates) throws Exception {

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group1.getGroupId());

    BaseModel<?> parentBaseModel = getParentBaseModel(_group1, serviceContext);

    final SearchContext searchContext = SearchContextTestUtil.getSearchContext();

    searchContext.setGroupIds(assetEntryQuery.getGroupIds());

    for (Date expirationDate : expirationDates) {
        addBaseModel(parentBaseModel, RandomTestUtil.randomString(), expirationDate, serviceContext);
    }/*from w  w w  . j  a  v  a  2s  . c o  m*/

    assetEntryQuery.setOrderByCol1("expirationDate");
    assetEntryQuery.setOrderByType1(orderByType);

    Arrays.sort(expirationDates);

    final DateFormat dateFormat = DateFormatFactoryUtil
            .getSimpleDateFormat(PropsValues.INDEX_DATE_FORMAT_PATTERN);

    List<AssetEntry> assetEntries = search(assetEntryQuery, searchContext);

    Assert.assertEquals(ArrayUtils.toString(format(expirationDates, dateFormat)),
            ArrayUtils.toString(format(getExpirationDates(assetEntries, orderByType), dateFormat)));
}

From source file:com.liferay.message.boards.service.test.MBMessageLocalServiceTest.java

License:Open Source License

@Test
public void testThreadLastPostDate() throws Exception {
    Date date = new Date();

    MBMessage parentMessage = addMessage(null, false, date);

    MBMessage firstReplyMessage = addMessage(parentMessage, false, new Date(date.getTime() + Time.SECOND));

    MBMessage secondReplyMessage = addMessage(parentMessage, false, new Date(date.getTime() + Time.SECOND * 2));

    DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat(PropsValues.INDEX_DATE_FORMAT_PATTERN);

    MBThread mbThread = parentMessage.getThread();

    Assert.assertEquals(dateFormat.format(mbThread.getLastPostDate()),
            dateFormat.format(secondReplyMessage.getModifiedDate()));

    MBMessageLocalServiceUtil.deleteMessage(secondReplyMessage.getMessageId());

    mbThread = parentMessage.getThread();

    Assert.assertEquals(dateFormat.format(mbThread.getLastPostDate()),
            dateFormat.format(firstReplyMessage.getModifiedDate()));
}