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


Java LocalDate.plusMonths方法代碼示例

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


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

示例1: getItemSearchStatisticsAsync

import java.time.LocalDate; //導入方法依賴的package包/類
/**
 * 異步獲取每日,每周,每月的統計數據
 * @return 統計列表包含每日,每周,每月的統計數據
 */
private List<ItemSearchStatisticDTO> getItemSearchStatisticsAsync() {
    List<ItemSearchStatisticDTO> itemSearchStatisticDTOList = new ArrayList<>(30);
    int size = 10;

    // 每日
    LocalDate todayDate = LocalDate.now();
    Future<List<Object[]>> itemDailySearchStatistics = findDateSearchStatistics(todayDate.toString(), size);
    // 每周
    LocalDate beforeWeekDate = todayDate.plusDays(-7);
    Future<List<Object[]>> itemWeeklySearchStatistics = findDateSearchStatistics(beforeWeekDate.toString(), size);
    // 每月
    LocalDate beforeMonthDate = todayDate.plusMonths(-30);
    Future<List<Object[]>> itemMonthlySearchStatistics = findDateSearchStatistics(beforeMonthDate.toString(), size);
    fillItemSearchStatisticList(itemSearchStatisticDTOList, itemDailySearchStatistics, ItemSearchStatisticDTO.DAILY);
    fillItemSearchStatisticList(itemSearchStatisticDTOList, itemWeeklySearchStatistics, ItemSearchStatisticDTO.WEEKLY);
    fillItemSearchStatisticList(itemSearchStatisticDTOList, itemMonthlySearchStatistics, ItemSearchStatisticDTO.MONTHLY);
    return itemSearchStatisticDTOList;
}
 
開發者ID:liufeng0103,項目名稱:bnade-web-ssh,代碼行數:23,代碼來源:StatisticService.java

示例2: createAuthenticationToken

import java.time.LocalDate; //導入方法依賴的package包/類
@Override
public String createAuthenticationToken(String email) {
    LocalDate currentDate = LocalDate.now();
    LocalDate nextMoth = currentDate.plusMonths(1) ;
    Date date = Date.from(nextMoth.atStartOfDay(ZoneId.systemDefault()).toInstant());
    String jwtToken = Jwts.builder()
            .setSubject(email)
            .setExpiration(date)
            .signWith(
                    SignatureAlgorithm.HS256,
                    SECURET.getBytes()
           )
            .compact();

    DBAuthenticationToken dbAuthenticationToken = new DBAuthenticationToken(email, jwtToken) ;
    tokenMapper.insert(dbAuthenticationToken);
    return jwtToken;
}
 
開發者ID:auslides,項目名稱:stateless-shiro,代碼行數:19,代碼來源:TokenRepositoryImpl.java

示例3: generateProductIncrementName

import java.time.LocalDate; //導入方法依賴的package包/類
private String generateProductIncrementName(int months){
    String pattern = "%1s-%2s";
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");

    LocalDate now = LocalDate.now();
    LocalDate changeMonthDate = now.plusMonths(months);
    String formattedChangeMonthDate = changeMonthDate.format(formatter);
    String formattedNow = now.format(formatter);

    return months < 0 ?
        String.format(pattern,formattedChangeMonthDate,formattedNow) :
        String.format(pattern,formattedNow ,formattedChangeMonthDate);
}
 
開發者ID:BBVA,項目名稱:mirrorgate,代碼行數:14,代碼來源:ProgramIncrementServiceTest.java

示例4: performAnimalEnrichment

import java.time.LocalDate; //導入方法依賴的package包/類
private static void performAnimalEnrichment(LocalDate start, LocalDate end) {
    LocalDate upTo = start;
    while (upTo.isBefore(end)) {
        System.out.println("give new toy: " + upTo);
        upTo = upTo.plusMonths(1);
    }
}
 
開發者ID:huby,項目名稱:java-se8-oca-study-guide,代碼行數:8,代碼來源:Zoo.java

示例5: test_plusMonths_long_invalidTooLargeMaxAddMax

import java.time.LocalDate; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMax() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MAX_VALUE);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKLocalDate.java

示例6: test_plusMonths_long_invalidTooLargeMaxAddMin

import java.time.LocalDate; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMin() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MIN_VALUE);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKLocalDate.java


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