本文整理匯總了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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}