Java取一日中的首尾秒

/**
 * 去当日首尾秒
 *
 * @param args
 */
public static void main(String[] args) {
    LocalDateTime now = LocalDateTime.now();
    System.out.println(now.with(LocalTime.MIN)); // 当日最早一秒:2023-03-30 00:00:00
    System.err.println(now.with(LocalTime.MAX));  // 当日最晚一秒:2023-03-30 23:59:59
}
posted @ 2023-03-30 15:25  JaxYoun  阅读(12)  评论(0编辑  收藏  举报