Skip to content

Commit 54ef332

Browse files
committed
Support java.time.LocalDate on a row
1 parent 2205ed5 commit 54ef332

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/main/scala/com/simple/jdub/Row.scala

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import java.sql.SQLXML
1616
import java.sql.Time
1717
import java.sql.Timestamp
1818
import java.time.Instant
19+
import java.time.LocalDate
1920
import java.time.LocalDateTime
2021
import java.util.UUID
2122

@@ -127,12 +128,12 @@ class Row(rs: ResultSet) {
127128
def bigDecimal(name: String): Option[BigDecimal] = extract(rs.getBigDecimal(name)).map { scala.math.BigDecimal(_) }
128129

129130
/**
130-
* Extract the value at the given offset as an Option[Array[Byte]].
131+
* Extract the value at the given offset as an `Option[Array[Byte]]`.
131132
*/
132133
def bytes(index: Int): Option[Array[Byte]] = extract(rs.getBytes(index + 1))
133134

134135
/**
135-
* Extract the value with the given name as an Option[Array[Byte]].
136+
* Extract the value with the given name as an `Option[Array[Byte]]`.
136137
*/
137138
def bytes(name: String): Option[Array[Byte]] = extract(rs.getBytes(name))
138139

@@ -154,7 +155,7 @@ class Row(rs: ResultSet) {
154155
/**
155156
* Extract the value with the given name as an Option[Time].
156157
*/
157-
def time(name: String) = extract(rs.getTime(name))
158+
def time(name: String): Option[Time] = extract(rs.getTime(name))
158159

159160
/**
160161
* Extract the value at the given offset as an Option[Timestamp].
@@ -186,6 +187,16 @@ class Row(rs: ResultSet) {
186187
*/
187188
def localDateTime(name: String): Option[LocalDateTime] = timestamp(name).map(_.toLocalDateTime)
188189

190+
/**
191+
* Extract the value at the given offset as an Option[LocalDate].
192+
*/
193+
def localDate(index: Int): Option[LocalDate] = localDateTime(index).map(_.toLocalDate)
194+
195+
/**
196+
* Extract the value with the given name as an Option[LocalDate].
197+
*/
198+
def localDate(name: String): Option[LocalDate] = localDateTime(name).map(_.toLocalDate)
199+
189200
/**
190201
* Extract the value with the given name as an Option[DateTime].
191202
*/

0 commit comments

Comments
 (0)