Skip to content

Commit

Permalink
feature: LocalDate.toYearMonth() 기능 선언
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryJhin committed Aug 11, 2024
1 parent 0102314 commit 2217adf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/kotlin/blog/jinhyun/java/time/JtLocalDateExtensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package blog.jinhyun.java.time

import java.time.LocalDate
import java.time.YearMonth

/**
* [LocalDate]의 연도와 월 정보를 [YearMonth]로 변환합니다.
*
* ```kotlin
* val date = LocalDate.of(2022, 1, 1)
* val yearMonth = date.toYearMonth()
* println(yearMonth) // 2022-01
* ```
*
* @receiver [LocalDate] 객체
* @return [YearMonth] 객체
*/
fun LocalDate.toYearMonth(): YearMonth = YearMonth.of(year, month)

0 comments on commit 2217adf

Please sign in to comment.