当前位置:网站首页>LocalDate加减操作及比较大小
LocalDate加减操作及比较大小
2022-07-31 03:19:00 【UlricaQ】
LocalDate做加减操作,代码及运行结果:
代码:
public void test() {
LocalDate today = LocalDate.now();
System.out.println("today:"+today);
// today加五天
LocalDate plusDays = today.plusDays(5);
System.out.println("today加5天:"+plusDays);
// today减5天
LocalDate minusDays = today.minusDays(5);
System.out.println("today减5天:"+minusDays);
// 判断today是否在plusDays之前,返回布尔值
boolean before = today.isBefore(plusDays);
System.out.println("判断today是否在plusDays之前:"+before);
boolean after = today.isAfter(plusDays);
System.out.println("判断today是否在plusDays之后:"+after);
// 比较today与plusDays,结果返回today-plusDays的值
int i = today.compareTo(plusDays);
System.out.println("today与plusDays比较大小:"+ i);
}
边栏推荐
猜你喜欢
随机推荐
SonarQube的BUG定义
MultipartFile file upload
Annotation usage meaning
浅识Flutter 基本组件之CheckBox组件
SQL injection Less47 (error injection) and Less49 (time blind injection)
Ambiguous method call.both
LeetCode简单题之找到和最大的长度为 K 的子序列
TCP和UDP详解
SQL 面试用题(重点)
想从手工测试转岗自动化测试,需要学习哪些技能?
SocialFi 何以成就 Web3 去中心化社交未来
Select the smoke test case, and make the first pass for the product package entering QA
IDEA comment report red solution
Office automation case: how to automatically generate period data?
选好冒烟测试用例,为进入QA的制品包把好第一道关
Web container and IIS --- Middleware penetration method 1
WebSocket Session为null
Redis implements distributed locks
SIP Protocol Standard and Implementation Mechanism
Mysql 45讲学习笔记(二十五)MYSQL保证高可用










