summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/app/passwordstore/ui/git/log/GitLogAdapter.kt8
-rw-r--r--app/src/main/java/app/passwordstore/util/extensions/Extensions.kt7
-rw-r--r--app/src/main/java/app/passwordstore/util/git/GitCommit.kt4
3 files changed, 9 insertions, 10 deletions
diff --git a/app/src/main/java/app/passwordstore/ui/git/log/GitLogAdapter.kt b/app/src/main/java/app/passwordstore/ui/git/log/GitLogAdapter.kt
index 29ffbe9b..9b7b77ed 100644
--- a/app/src/main/java/app/passwordstore/ui/git/log/GitLogAdapter.kt
+++ b/app/src/main/java/app/passwordstore/ui/git/log/GitLogAdapter.kt
@@ -11,8 +11,8 @@ import androidx.recyclerview.widget.RecyclerView
import app.passwordstore.databinding.GitLogRowLayoutBinding
import app.passwordstore.util.git.GitCommit
import app.passwordstore.util.git.GitLogModel
-import java.text.DateFormat
-import java.util.Date
+import java.time.Instant
+import java.time.format.DateTimeFormatter
import logcat.LogPriority.ERROR
import logcat.logcat
@@ -20,8 +20,8 @@ private fun shortHash(hash: String): String {
return hash.substring(0 until 8)
}
-private fun stringFrom(date: Date): String {
- return DateFormat.getDateTimeInstance().format(date)
+private fun stringFrom(date: Instant): String {
+ return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(date)
}
/** @see GitLogActivity */
diff --git a/app/src/main/java/app/passwordstore/util/extensions/Extensions.kt b/app/src/main/java/app/passwordstore/util/extensions/Extensions.kt
index c0b40aa4..c6fd9ceb 100644
--- a/app/src/main/java/app/passwordstore/util/extensions/Extensions.kt
+++ b/app/src/main/java/app/passwordstore/util/extensions/Extensions.kt
@@ -10,7 +10,7 @@ import com.github.michaelbull.result.Result
import com.github.michaelbull.result.getOrElse
import com.github.michaelbull.result.runCatching
import java.io.File
-import java.util.Date
+import java.time.Instant
import logcat.asLog
import org.eclipse.jgit.lib.ObjectId
import org.eclipse.jgit.revwalk.RevCommit
@@ -57,11 +57,10 @@ val RevCommit.hash: String
*
* @see RevCommit.commitTime
*/
-val RevCommit.time: Date
+val RevCommit.time: Instant
get() {
val epochSeconds = commitTime.toLong()
- val epochMilliseconds = epochSeconds * 1000
- return Date(epochMilliseconds)
+ return Instant.ofEpochSecond(epochSeconds)
}
/** Alias to [lazy] with thread safety mode always set to [LazyThreadSafetyMode.NONE]. */
diff --git a/app/src/main/java/app/passwordstore/util/git/GitCommit.kt b/app/src/main/java/app/passwordstore/util/git/GitCommit.kt
index 0a5d2020..559b0e4a 100644
--- a/app/src/main/java/app/passwordstore/util/git/GitCommit.kt
+++ b/app/src/main/java/app/passwordstore/util/git/GitCommit.kt
@@ -5,7 +5,7 @@
package app.passwordstore.util.git
-import java.util.Date
+import java.time.Instant
/**
* Basic information about a git commit.
@@ -19,5 +19,5 @@ data class GitCommit(
val hash: String,
val shortMessage: String,
val authorName: String,
- val time: Date
+ val time: Instant
)