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


Java LocalDateTime.withMinute方法代碼示例

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


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

示例1: test_withMinute_normal

import java.time.LocalDateTime; //導入方法依賴的package包/類
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:TCKLocalDateTime.java

示例2: makeDatesEven

import java.time.LocalDateTime; //導入方法依賴的package包/類
private List<LocalDateTime> makeDatesEven(List<LocalDateTime> dates, LocalDateTime dateTime) {
    // If the dates contain more dates than just the lower and upper bounds, make the dates in between even.
    if (dates.size() > 2) {
        List<LocalDateTime> evenDates = new ArrayList<>();

        // For each interval, modify the date slightly by a few millis, to make sure they are different days.
        // This is because Axis stores each value and won't update the tick labels, if the value is already known.
        // This happens if you display days and then add a date many years in the future the tick label will still be displayed as day.
        for (int i = 0; i < dates.size(); i++) {
            dateTime = dates.get(i);
            switch (currentInterval.getInterval()) {
                case YEARS:
                    // If its not the first or last date (lower and upper bound), make the year begin with first month and let the months begin with first day.
                    if (i != 0 && i != dates.size() - 1) {
                        dateTime.withMonth(1);
                        dateTime.withDayOfMonth(1);
                    }
                    dateTime.withHour(0);
                    dateTime.withMinute(0);
                    dateTime.withSecond(0);
                    dateTime.withNano(6000000);
                    break;
                case MONTHS:
                    // If its not the first or last date (lower and upper bound), make the months begin with first day.
                    if (i != 0 && i != dates.size() - 1) {
                        dateTime.withDayOfMonth(1);
                    }
                    dateTime.withHour(0);
                    dateTime.withMinute(0);
                    dateTime.withSecond(0);
                    dateTime.withNano(5000000);
                    break;
                case WEEKS:
                    // Make weeks begin with first day of week?
                    dateTime.withHour(0);
                    dateTime.withMinute(0);
                    dateTime.withSecond(0);
                    dateTime.withNano(4000000);
                    break;
                case DAYS:
                    dateTime.withHour(0);
                    dateTime.withMinute(0);
                    dateTime.withSecond(0);
                    dateTime.withNano(3000000);
                    break;
                case HOURS:
                    if (i != 0 && i != dates.size() - 1) {
                        dateTime.withMinute(0);
                        dateTime.withSecond(0);
                    }
                    dateTime.withNano(2000000);
                    break;
                case MINUTES:
                    if (i != 0 && i != dates.size() - 1) {
                        dateTime.withSecond(0);
                    }
                    dateTime.withNano(1000000);
                    break;
                case SECONDS:
                    dateTime.withSecond(0);
                    break;

            }
            evenDates.add(dateTime);
        }

        return evenDates;
    } else {
        return dates;
    }
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:72,代碼來源:Axis.java


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