Skip to content

Commit

Permalink
Fix formatting of instant into string (#62)
Browse files Browse the repository at this point in the history
* Fix instant to string issue for S3

* Adds formatted instant test

* Formatting, import optimizing, removal of misleading with clause
  • Loading branch information
LDonoughe-mdsol committed Dec 9, 2022
1 parent 1adfff0 commit 8fbed1b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
@@ -1,12 +1,12 @@
package io.epiphanous.flinkrunner.util

import java.time.Instant
import java.time.{Instant, ZoneOffset}
import java.time.format.DateTimeFormatter

object InstantUtils {

val dtf: DateTimeFormatter =
DateTimeFormatter.ofPattern("/yyyy/MM/dd/HH")
DateTimeFormatter.ofPattern("/yyyy/MM/dd/HH").withZone(ZoneOffset.UTC)

implicit class RichInstant(instant: Instant) {
def prefixedTimePath(prefix: String): String =
Expand Down
@@ -0,0 +1,24 @@
package io.epiphanous.flinkrunner.util

import io.epiphanous.flinkrunner.PropSpec
import io.epiphanous.flinkrunner.util.InstantUtils.RichInstant

import java.time.Instant

class InstantUtilsTest extends PropSpec {

property("Adds Prefix") {
val prefix = "prefix"
val zero_time = RichInstant(Instant.ofEpochSecond(0))
val formatted_string = "prefix/1970/01/01/00"
zero_time.prefixedTimePath(prefix) shouldEqual formatted_string
}

property("does not need a prefix") {
val prefix = ""
val zero_time = RichInstant(Instant.ofEpochSecond(0))
val formatted_string = "/1970/01/01/00"
zero_time.prefixedTimePath(prefix) shouldEqual formatted_string
}

}

0 comments on commit 8fbed1b

Please sign in to comment.