當前位置: 首頁>>代碼示例>>Java>>正文


Java DateUtils.truncate方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.time.DateUtils.truncate方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.truncate方法的具體用法?Java DateUtils.truncate怎麽用?Java DateUtils.truncate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.time.DateUtils的用法示例。


在下文中一共展示了DateUtils.truncate方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testDatastorePropertyBox

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@Test
@Transactional
public void testDatastorePropertyBox() {

	final Date now = DateUtils.truncate(new Date(), Calendar.DATE);
	final BigDecimal bd = new BigDecimal(7);

	PropertyBox box = PropertyBox.builder(PROPS).set(KEY, 22L).set(STR, "Test22").set(DBL, 2.3).set(DAT, now)
			.set(ENM, TestEnum.THIRD).set(NBOOL, Boolean.TRUE).set(NST_STR, "NestedStr").set(NST_DEC, bd).build();

	getDatastore().save(ENTITY_TARGET, box);

	Optional<PropertyBox> fnd = getDatastore().query().target(NAMED_TARGET).filter(KEY.eq(22L)).findOne(PROPS);
	assertTrue(fnd.isPresent());

	PropertyBox found = fnd.get();

	assertEquals(new Long(22), found.getValue(KEY));
	assertEquals("Test22", found.getValue(STR));
	assertEquals(new Double(2.3), found.getValue(DBL));
	assertEquals(now, found.getValue(DAT));
	assertEquals(TestEnum.THIRD, found.getValue(ENM));
	assertEquals("NestedStr", found.getValue(NST_STR));
	assertEquals((Double) bd.doubleValue(), (Double) found.getValue(NST_DEC).doubleValue());

	getDatastore().delete(NAMED_TARGET, found);

	Optional<String> str = getDatastore().query().target(NAMED_TARGET).filter(KEY.eq(22L)).findOne(STR);
	assertFalse(str.isPresent());

}
 
開發者ID:holon-platform,項目名稱:holon-datastore-jpa,代碼行數:32,代碼來源:AbstractJpaDatastoreTest.java

示例2: createEdges

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
private List<Edge> createEdges(final String line) {
    final String[] t = line.split(",");

    final String road = t[0];
    final String junctionA = t[1];
    final String junctionB = t[2];
    final Date timestamp;
    try {
        timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(t[3]);
    } catch (final ParseException e) {
        throw new IllegalArgumentException("Invalid date: " + t[3]);
    }

    final Date startDate = DateUtils.truncate(timestamp, Calendar.DAY_OF_MONTH);
    final Date endDate = DateUtils.addMilliseconds(DateUtils.addDays(startDate, 1), -1);

    return Arrays.asList(
            new Edge.Builder()
                    .group("RoadHasJunction")
                    .source(road)
                    .dest(junctionA)
                    .directed(true)
                    .build(),

            new Edge.Builder()
                    .group("RoadHasJunction")
                    .source(road)
                    .dest(junctionB)
                    .directed(true)
                    .build(),

            new Edge.Builder()
                    .group("RoadUse")
                    .source(junctionA)
                    .dest(junctionB)
                    .directed(true)
                    .property("count", 1L)
                    .property("startDate", startDate)
                    .property("endDate", endDate)
                    .build()
    );
}
 
開發者ID:gchq,項目名稱:gaffer-doc,代碼行數:43,代碼來源:RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator.java

示例3: _apply

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@Override
public Iterable<Element> _apply(final String line) {
    final String[] t = line.split(",");

    final String road = t[0];
    final String junctionA = t[1];
    final String junctionB = t[2];
    final Date timestamp;
    try {
        timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(t[3]);
    } catch (final ParseException e) {
        throw new IllegalArgumentException("Invalid date: " + t[3]);
    }

    final Date startDate = DateUtils.truncate(timestamp, Calendar.DAY_OF_MONTH);
    final Date endDate = DateUtils.addMilliseconds(DateUtils.addDays(startDate, 1), -1);

    return Arrays.asList(
            new Edge.Builder()
                    .group("RoadHasJunction")
                    .source(road)
                    .dest(junctionA)
                    .directed(true)
                    .build(),

            new Edge.Builder()
                    .group("RoadHasJunction")
                    .source(road)
                    .dest(junctionB)
                    .directed(true)
                    .build(),

            new Edge.Builder()
                    .group("RoadUse")
                    .source(junctionA)
                    .dest(junctionB)
                    .directed(true)
                    .property("count", 1L)
                    .property("startDate", startDate)
                    .property("endDate", endDate)
                    .build()
    );
}
 
開發者ID:gchq,項目名稱:gaffer-doc,代碼行數:44,代碼來源:RoadAndRoadUseWithTimesElementGenerator.java

示例4: getDateRange

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
private Range<Date> getDateRange() {
    Date endDate = DateUtils.truncate(new Date(), Calendar.MINUTE);
    Date startDate = DateUtils.addMinutes(endDate,
            -YiDuConstants.yiduConf.getInt(YiDuConfig.SEND_SUBSCRIBE_INTEVAL, 15));
    return Range.between(startDate, endDate);
}
 
開發者ID:luckyyeah,項目名稱:YiDu-Novel,代碼行數:7,代碼來源:SendSubscribeMailJob.java

示例5: toStartOfDay

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
public static Date toStartOfDay(final Date date) {
    return DateUtils.truncate(date, Calendar.DATE);
}
 
開發者ID:spypunk,項目名稱:endpoint-health,代碼行數:4,代碼來源:Utils.java

示例6: doScanLibrary

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
private void doScanLibrary() {
    LOG.info("Starting to scan media library.");
    Date lastScanned = DateUtils.truncate(new Date(), Calendar.SECOND);
    LOG.debug("New last scan date is " + lastScanned);

    try {

        // Maps from artist name to album count.
        Map<String, Integer> albumCount = new HashMap<String, Integer>();
        Genres genres = new Genres();

        scanCount = 0;
        statistics.reset();

        mediaFileService.setMemoryCacheEnabled(false);
        searchService.startIndexing();

        mediaFileService.clearMemoryCache();

        // Recurse through all files on disk.
        for (MusicFolder musicFolder : settingsService.getAllMusicFolders()) {
            MediaFile root = mediaFileService.getMediaFile(musicFolder.getPath(), false);
            scanFile(root, musicFolder, lastScanned, albumCount, genres, false);
        }

        // Scan podcast folder.
        File podcastFolder = new File(settingsService.getPodcastFolder());
        if (podcastFolder.exists()) {
            scanFile(mediaFileService.getMediaFile(podcastFolder), new MusicFolder(podcastFolder, null, true, null),
                     lastScanned, albumCount, genres, true);
        }

        LOG.info("Scanned media library with " + scanCount + " entries.");

        LOG.info("Marking non-present files.");
        mediaFileDao.markNonPresent(lastScanned);
        LOG.info("Marking non-present artists.");
        artistDao.markNonPresent(lastScanned);
        LOG.info("Marking non-present albums.");
        albumDao.markNonPresent(lastScanned);

        // Update statistics
        statistics.incrementArtists(albumCount.size());
        for (Integer albums : albumCount.values()) {
            statistics.incrementAlbums(albums);
        }

        // Update genres
        mediaFileDao.updateGenres(genres.getGenres());

        settingsService.setMediaLibraryStatistics(statistics);
        settingsService.setLastScanned(lastScanned);
        settingsService.save(false);
        LOG.info("Completed media library scan.");

    } catch (Throwable x) {
        LOG.error("Failed to scan media library.", x);
    } finally {
        mediaFileService.setMemoryCacheEnabled(true);
        searchService.stopIndexing();
        scanning = false;
    }
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:64,代碼來源:MediaScannerService.java

示例7: beginOfYear

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * 2016-11-10 07:33:23, 則返回2016-1-1 00:00:00
 */
public static Date beginOfYear(@NotNull final Date date) {
	return DateUtils.truncate(date, Calendar.YEAR);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:7,代碼來源:DateUtil.java

示例8: beginOfMonth

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * 2016-11-10 07:33:23, 則返回2016-11-1 00:00:00
 */
public static Date beginOfMonth(@NotNull final Date date) {
	return DateUtils.truncate(date, Calendar.MONTH);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:7,代碼來源:DateUtil.java

示例9: beginOfWeek

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * 2017-1-20 07:33:23, 則返回2017-1-16 00:00:00
 */
public static Date beginOfWeek(@NotNull final Date date) {
	return DateUtils.truncate(DateUtil.subDays(date, DateUtil.getDayOfWeek(date) - 1), Calendar.DATE);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:7,代碼來源:DateUtil.java

示例10: nextWeek

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * 2017-1-23 07:33:23, 則返回2017-1-22 00:00:00
 */
public static Date nextWeek(@NotNull final Date date) {
	return DateUtils.truncate(DateUtil.addDays(date, 8 - DateUtil.getDayOfWeek(date)), Calendar.DATE);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:7,代碼來源:DateUtil.java

示例11: beginOfDate

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * 2016-11-10 07:33:23, 則返回2016-11-10 00:00:00
 */
public static Date beginOfDate(@NotNull final Date date) {
	return DateUtils.truncate(date, Calendar.DATE);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:7,代碼來源:DateUtil.java

示例12: beginOfHour

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * 2016-12-10 07:33:23, 則返回2016-12-10 07:00:00
 */
public static Date beginOfHour(@NotNull final Date date) {
	return DateUtils.truncate(date, Calendar.HOUR_OF_DAY);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:7,代碼來源:DateUtil.java

示例13: beginOfMinute

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * 2016-12-10 07:33:23, 則返回2016-12-10 07:33:00
 */
public static Date beginOfMinute(@NotNull final Date date) {
	return DateUtils.truncate(date, Calendar.MINUTE);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:7,代碼來源:DateUtil.java

示例14: postTreatment

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@Override
public Date postTreatment(final Date date) {
	return DateUtils.truncate(date, java.util.Calendar.DATE);
}
 
開發者ID:ligoj,項目名稱:plugin-bt-jira,代碼行數:5,代碼來源:DatePickerEditor.java


注:本文中的org.apache.commons.lang3.time.DateUtils.truncate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。