代码示例
LocalDateTime now = LocalDateTime.now();
int year = now.getYear();
int month = now.getMonthValue();
int day = now.getDayOfMonth();
System.out.println(String.format("%d-%d-%d", year, month, day));
// 2023-4-21
LocalDateTime startTime = LocalDateTime.of(year, month, day, 0, 0, 0);
LocalDateTime endTime = LocalDateTime.of(year, month, day, 23, 59, 59);
System.out.println(startTime);
// 2023-04-21T00:00
System.out.println(endTime);
// 2023-04-21T23:59:59
————————————————
版权声明:本文为CSDN博主「彭世瑜」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。