Skip to content

Commit f119dc8

Browse files
authored
Fix incorrect currentTime() for Android devices on API 25 and blow
Also add millisecond precision
1 parent df49eef commit f119dc8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/library-base/src/androidMain/kotlin/io/realm/kotlin/internal/platform/SystemUtilsAndroid.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public actual fun currentTime(): RealmInstant {
4444
val jtInstant = java.time.Clock.systemUTC().instant()
4545
RealmInstantImpl(jtInstant.epochSecond, jtInstant.nano)
4646
} else {
47-
RealmInstantImpl(System.currentTimeMillis(), 0)
47+
val now = System.currentTimeMillis()
48+
RealmInstantImpl(now / 1000, (now % 1000).toInt() * 1_000_000)
4849
}
4950
}

0 commit comments

Comments
 (0)