本文整理汇总了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);
}