8000 Don't use a formatter with an optional value when producing times - f… · antonzherdev/postgresql-async@8d20500 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d20500

Browse files
committed
Don't use a formatter with an optional value when producing times - fixes mauricio#142
1 parent 708e2fc commit 8d20500

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

db-async-common/src/main/scala/com/github/mauricio/async/db/column/TimeEncoderDecoder.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ class TimeEncoderDecoder extends ColumnEncoderDecoder {
3333
.appendOptional(optional)
3434
.toFormatter
3535

36+
final private val printer = new DateTimeFormatterBuilder()
37+
.appendPattern("HH:mm:ss.SSSSSS")
38+
.toFormatter
39+
3640
def formatter = format
3741

38-
override def decode(value: String): LocalTime = {
42+
override def decode(value: String): LocalTime =
3943
format.parseLocalTime(value)
40-
}
4144

42-
override def encode(value: Any): String = {
43-
this.format.print(value.asInstanceOf[LocalTime])
44-
}
45+
override def encode(value: Any): String =
46+
this.printer.print(value.asInstanceOf[LocalTime])
4547

4648
}

0 commit comments

Comments
 (0)
0