fix(app): fully migrate to java.time
This commit is contained in:
parent
bed8ec76e3
commit
d37fdfdbaa
3 changed files with 9 additions and 10 deletions
|
@ -11,8 +11,8 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import app.passwordstore.databinding.GitLogRowLayoutBinding
|
import app.passwordstore.databinding.GitLogRowLayoutBinding
|
||||||
import app.passwordstore.util.git.GitCommit
|
import app.passwordstore.util.git.GitCommit
|
||||||
import app.passwordstore.util.git.GitLogModel
|
import app.passwordstore.util.git.GitLogModel
|
||||||
import java.text.DateFormat
|
import java.time.Instant
|
||||||
import java.util.Date
|
import java.time.format.DateTimeFormatter
|
||||||
import logcat.LogPriority.ERROR
|
import logcat.LogPriority.ERROR
|
||||||
import logcat.logcat
|
import logcat.logcat
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ private fun shortHash(hash: String): String {
|
||||||
return hash.substring(0 until 8)
|
return hash.substring(0 until 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stringFrom(date: Date): String {
|
private fun stringFrom(date: Instant): String {
|
||||||
return DateFormat.getDateTimeInstance().format(date)
|
return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(date)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see GitLogActivity */
|
/** @see GitLogActivity */
|
||||||
|
|
|
@ -10,7 +10,7 @@ import com.github.michaelbull.result.Result
|
||||||
import com.github.michaelbull.result.getOrElse
|
import com.github.michaelbull.result.getOrElse
|
||||||
import com.github.michaelbull.result.runCatching
|
import com.github.michaelbull.result.runCatching
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Date
|
import java.time.Instant
|
||||||
import logcat.asLog
|
import logcat.asLog
|
||||||
import org.eclipse.jgit.lib.ObjectId
|
import org.eclipse.jgit.lib.ObjectId
|
||||||
import org.eclipse.jgit.revwalk.RevCommit
|
import org.eclipse.jgit.revwalk.RevCommit
|
||||||
|
@ -57,11 +57,10 @@ val RevCommit.hash: String
|
||||||
*
|
*
|
||||||
* @see RevCommit.commitTime
|
* @see RevCommit.commitTime
|
||||||
*/
|
*/
|
||||||
val RevCommit.time: Date
|
val RevCommit.time: Instant
|
||||||
get() {
|
get() {
|
||||||
val epochSeconds = commitTime.toLong()
|
val epochSeconds = commitTime.toLong()
|
||||||
val epochMilliseconds = epochSeconds * 1000
|
return Instant.ofEpochSecond(epochSeconds)
|
||||||
return Date(epochMilliseconds)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Alias to [lazy] with thread safety mode always set to [LazyThreadSafetyMode.NONE]. */
|
/** Alias to [lazy] with thread safety mode always set to [LazyThreadSafetyMode.NONE]. */
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
package app.passwordstore.util.git
|
package app.passwordstore.util.git
|
||||||
|
|
||||||
import java.util.Date
|
import java.time.Instant
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic information about a git commit.
|
* Basic information about a git commit.
|
||||||
|
@ -19,5 +19,5 @@ data class GitCommit(
|
||||||
val hash: String,
|
val hash: String,
|
||||||
val shortMessage: String,
|
val shortMessage: String,
|
||||||
val authorName: String,
|
val authorName: String,
|
||||||
val time: Date
|
val time: Instant
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue