[BadCase]日期格式统一

This commit is contained in:
renwj
2022-01-27 14:52:27 +08:00
parent 130275cfc2
commit 2236fda2f2
3 changed files with 7 additions and 7 deletions

View File

@@ -46,7 +46,7 @@ class AutoPilotBadCaseTest {
it.key = "yyy_$index"
it.stat = 100
it.type = 1
it.timestamp = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Date())
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
index++
})
}
@@ -77,7 +77,7 @@ class AutoPilotBadCaseTest {
it.key = "yyy_$index"
it.stat = 100
it.type = 1
it.timestamp = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Date())
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
index++
})
@@ -108,7 +108,7 @@ class AutoPilotBadCaseTest {
it.key = "yyy_$index"
it.stat = 100
it.type = 1
it.timestamp = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Date())
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
index++
})
}

View File

@@ -107,7 +107,7 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
Log.d("QQQ", "-- step -- 1 --")
var oldT = try {
old?.timestamp?.takeIf { it.isNotBlank() }?.let {
SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault()).parse(it)?.time ?: 0L
SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).parse(it)?.time ?: 0L
} ?: 0L
} catch (t: Throwable) {
t.printStackTrace()
@@ -116,7 +116,7 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
var record: AutoPilotRecordResult? = null
var newT = try {
it.receive()?.also { record = it }?.timestamp?.takeIf { it.isNotBlank() }?.let {
SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault()).parse(it)?.time
SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).parse(it)?.time
?: 0L
} ?: 0L
} catch (t: Throwable) {
@@ -140,7 +140,7 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
it.receive()?.also {
record = it
}?.timestamp?.takeIf { it.isNotBlank() }?.let {
SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault()).parse(it)?.time ?: 0L
SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).parse(it)?.time ?: 0L
} ?: 0L
} catch (t: Throwable) {
t.printStackTrace()

View File

@@ -63,7 +63,7 @@ class AutoPilotRecordResult {
* 时间戳格式YYYY-MM-DD-hh-mm-ss
*/
@PrimaryKey
var timestamp: String = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault()).format(Date())
var timestamp: String = SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).format(Date())
/**
* 此次采集数据总大小M