Fix timestamp of validation data
This commit is contained in:
@@ -529,10 +529,13 @@ public class SensorValidationActivity extends AppCompatActivity {
|
||||
|
||||
double averageHr = currentHrValidCount > 0 ? currentHrSum / currentHrValidCount : -1.0;
|
||||
long timestampMillis = hrStartMillis + currentHrSecond * 1000L;
|
||||
String timestampIso = timestampIsoLocal(timestampMillis);
|
||||
String timestamp = new SimpleDateFormat("HH:mm:ss", Locale.UK).format(new Date(timestampMillis));
|
||||
|
||||
hrPoints.add(new HeartRatePoint(
|
||||
hrPoints.size(),
|
||||
timestampIso,
|
||||
timestampMillis,
|
||||
timestamp,
|
||||
currentHrSecond,
|
||||
averageHr,
|
||||
@@ -605,9 +608,11 @@ public class SensorValidationActivity extends AppCompatActivity {
|
||||
File file = new File(getOutputDir(), "validation_hr_" + timestampForFilename() + ".csv");
|
||||
try {
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file));
|
||||
writer.write("point_index,time_hhmmss,elapsed_seconds,avg_hr_bpm,valid,valid_readings_in_second,total_readings_in_second\n");
|
||||
writer.write("point_index,timestamp_iso,epoch_ms,time_hhmmss,elapsed_seconds,avg_hr_bpm,valid,valid_readings_in_second,total_readings_in_second\n");
|
||||
for (HeartRatePoint point : hrPoints) {
|
||||
writer.write(point.index + ","
|
||||
+ point.timestampIso + ","
|
||||
+ point.epochMillis + ","
|
||||
+ point.timestampHhMmSs + ","
|
||||
+ point.elapsedSecond + ","
|
||||
+ (point.valid ? String.format(Locale.UK, "%.3f", point.averageHr) : "") + ","
|
||||
@@ -625,6 +630,8 @@ public class SensorValidationActivity extends AppCompatActivity {
|
||||
|
||||
private static class HeartRatePoint {
|
||||
final int index;
|
||||
final String timestampIso;
|
||||
final long epochMillis;
|
||||
final String timestampHhMmSs;
|
||||
final int elapsedSecond;
|
||||
final double averageHr;
|
||||
@@ -633,12 +640,16 @@ public class SensorValidationActivity extends AppCompatActivity {
|
||||
final int readingsInSecond;
|
||||
|
||||
HeartRatePoint(int index,
|
||||
String timestampIso,
|
||||
long epochMillis,
|
||||
String timestampHhMmSs,
|
||||
int elapsedSecond,
|
||||
double averageHr,
|
||||
int validReadingsInSecond,
|
||||
int readingsInSecond) {
|
||||
this.index = index;
|
||||
this.timestampIso = timestampIso;
|
||||
this.epochMillis = epochMillis;
|
||||
this.timestampHhMmSs = timestampHhMmSs;
|
||||
this.elapsedSecond = elapsedSecond;
|
||||
this.averageHr = averageHr;
|
||||
@@ -661,6 +672,11 @@ public class SensorValidationActivity extends AppCompatActivity {
|
||||
return new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.UK).format(new Date());
|
||||
}
|
||||
|
||||
private static String timestampIsoLocal(long millis) {
|
||||
// ISO-like local timestamp with timezone offset, for example: 2026-05-05T10:24:25.000+0000
|
||||
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.UK).format(new Date(millis));
|
||||
}
|
||||
|
||||
private void saveRawCsv() {
|
||||
if (lastResult == null) return;
|
||||
File file = new File(getOutputDir(), "validation_raw_" + timestampForFilename() + ".csv");
|
||||
|
||||
Reference in New Issue
Block a user