-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Oppdater BeløpshistorikkGrunnlag (#436)
* Oppdater BeløpshistorikkGrunnlag * Oppdater BeløpshistorikkGrunnlag
- Loading branch information
Showing
5 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/felles/DateUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
package no.nav.bidrag.transport.felles | ||
|
||
import java.time.LocalDate | ||
import java.time.LocalDateTime | ||
import java.time.YearMonth | ||
import java.time.format.DateTimeFormatter | ||
|
||
val formatterCompact = DateTimeFormatter.ofPattern("yyyyMMdd") | ||
val formatterCompactLocalDateTime = DateTimeFormatter.ofPattern("yyyyMMddHHmmss") | ||
val formatterCompactYearMonth = DateTimeFormatter.ofPattern("yyyyMM") | ||
|
||
fun LocalDate?.toCompactString(): String = this?.format(formatterCompact) ?: "" | ||
|
||
fun LocalDateTime?.toCompactString(): String = this?.format(formatterCompactLocalDateTime) ?: "" | ||
|
||
fun YearMonth?.toCompactString(): String = this?.format(formatterCompactYearMonth) ?: "" |
13 changes: 13 additions & 0 deletions
13
bidrag-transport/src/test/kotlin/no/nav/bidrag/transport/felles/DateUtilsKtTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package no.nav.bidrag.transport.felles | ||
|
||
import io.kotest.matchers.shouldBe | ||
import java.time.LocalDateTime | ||
import kotlin.test.Test | ||
|
||
class DateUtilsKtTest { | ||
@Test | ||
fun `skal konvertere dato til string`() { | ||
val dato = LocalDateTime.of(2021, 1, 1, 2, 3, 4) | ||
dato.toCompactString() shouldBe "20210101020304" | ||
} | ||
} |