DateUtils

날짜/시간 유틸리티 함수 모음.

기본 함수

now(zoneId)

fun now(zoneId: String = Constants.ASIA_SEOUL): LocalDateTime

현재 시간 반환. 기본 Asia/Seoul.

today(zoneId)

fun today(zoneId: String? = Constants.ASIA_SEOUL): LocalDate
fun today(zoneId: ZoneId): LocalDate

오늘 날짜 반환.

확장 함수

LocalDate.between(from, to)

fun LocalDate.between(from: LocalDate, to: LocalDate): Boolean

날짜가 범위 내인지 확인 (from, to 포함).

LocalDateTime.differ(to)

infix fun LocalDateTime.differ(to: LocalDateTime): Duration

두 시간 사이 Duration 계산.

LocalTime.between(date1, date2)

fun LocalTime.between(date1: LocalTime, date2: LocalTime): Boolean

시간이 범위 내인지 확인 (date1 포함, date2 미포함).

toKST(zoneId)

fun LocalDateTime.toKST(zoneId: ZoneId = ZoneId.of("UTC")): LocalDateTime

UTC → KST 변환.

toStringFormat(format)

fun LocalDate.toStringFormat(format: String): String
fun LocalTime.toStringFormat(format: String): String
fun LocalDateTime.toStringFormat(format: String): String

포맷 문자열로 변환.

사용처

  • 시간대 변환
  • 날짜 범위 검증
  • 비행시간 계산