Skip to content

Commit

Permalink
fix string to timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiguif committed Jan 31, 2020
1 parent 7cfd3e6 commit 4e263ce
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.threeten.bp.Instant
import org.threeten.bp.LocalDate
import org.threeten.bp.LocalDateTime
import org.threeten.bp.ZoneOffset
import org.threeten.bp.LocalTime
import org.threeten.bp.format.DateTimeFormatter


Expand All @@ -12,7 +13,7 @@ object DateFormatter{
const val DEFAULT_DATE_FORMAT: String = "dd/MM/yyyy"

fun stringToTimestamp(date: String): Float{
return LocalDate.parse(date).atStartOfDay()
return LocalDate.parse(date).atTime(LocalTime.MIDNIGHT)
.toInstant(ZoneOffset.UTC).epochSecond.toFloat()
}

Expand Down

0 comments on commit 4e263ce

Please sign in to comment.