inblog logo
|
gyul
    자바 (JAVA)

    [자바 (JAVA)] 29. ChoronoUnit

    귤's avatar
    귤
    Feb 13, 2025
    [자바 (JAVA)] 29. ChoronoUnit
    Contents
    1. ChronoUnit2. ChronoUnit을 사용하여 시간차 구하기

    1. ChronoUnit

    💡
    시간의 양을 특정 시간 단위로 측정하는 데 사용되는 API이다.

    2. 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 + "분전"); } }
    notion image
     
    Share article

    gyul

    RSS·Powered by Inblog