[자바 Utils&LIb] 47. JRE 라이브러리 (ChronoUnit)

김건우's avatar
Feb 12, 2025
[자바 Utils&LIb] 47. JRE 라이브러리 (ChronoUnit)
💡
시간의 단위를 표현하는 구현체로 다양한 단위를 제공
package ex08; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; public class Chrono01 { public static void main(String[] args) { LocalDateTime writeTime = LocalDateTime.of(2025, 02, 11, 10, 3); LocalDateTime nowTime = LocalDateTime.now(); long daysBetween = ChronoUnit.DAYS.between(nowTime, writeTime); long minsBetween = ChronoUnit.MINUTES.between(nowTime, writeTime); System.out.println(daysBetween + "일전"); System.out.println(minsBetween + "분전"); } }
berween → 두 Temporal 객체 사이의 시간을 현재 ChroboUnit 단위로 측정하여 반환
notion image
Share article

gunwoo