From 98edf1fbc777ef7d41a70cf5655feb64c4fa2378 Mon Sep 17 00:00:00 2001 From: agnostic-apollo Date: Thu, 19 Aug 2021 18:26:52 +0500 Subject: [PATCH] Changed: Use millisecond timestamps for reports --- .../main/java/com/termux/shared/crash/CrashHandler.java | 2 +- .../src/main/java/com/termux/shared/models/ReportInfo.java | 2 +- .../main/java/com/termux/shared/termux/AndroidUtils.java | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/termux-shared/src/main/java/com/termux/shared/crash/CrashHandler.java b/termux-shared/src/main/java/com/termux/shared/crash/CrashHandler.java index f8d7f60e01..7b920f7568 100644 --- a/termux-shared/src/main/java/com/termux/shared/crash/CrashHandler.java +++ b/termux-shared/src/main/java/com/termux/shared/crash/CrashHandler.java @@ -56,7 +56,7 @@ public static void logCrash(@NonNull final Context context, @NonNull final Crash reportString.append("## Crash Details\n"); reportString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Crash Thread", thread.toString(), "-")); - reportString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Crash Timestamp", AndroidUtils.getCurrentTimeStamp(), "-")); + reportString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Crash Timestamp", AndroidUtils.getCurrentMilliSecondUTCTimeStamp(), "-")); reportString.append("\n\n").append(MarkdownUtils.getMultiLineMarkdownStringEntry("Crash Message", throwable.getMessage(), "-")); reportString.append("\n\n").append(Logger.getStackTracesMarkdownString("Stacktrace", Logger.getStackTracesStringArray(throwable))); diff --git a/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java b/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java index fdb648b239..ebecdd5af5 100644 --- a/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java +++ b/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java @@ -34,7 +34,7 @@ public ReportInfo(String userAction, String sender, String reportTitle, String r this.reportString = reportString; this.reportStringSuffix = reportStringSuffix; this.addReportInfoToMarkdown = addReportInfoToMarkdown; - this.reportTimestamp = AndroidUtils.getCurrentTimeStamp(); + this.reportTimestamp = AndroidUtils.getCurrentMilliSecondUTCTimeStamp(); } /** diff --git a/termux-shared/src/main/java/com/termux/shared/termux/AndroidUtils.java b/termux-shared/src/main/java/com/termux/shared/termux/AndroidUtils.java index 418f7d85aa..d433402a2b 100644 --- a/termux-shared/src/main/java/com/termux/shared/termux/AndroidUtils.java +++ b/termux-shared/src/main/java/com/termux/shared/termux/AndroidUtils.java @@ -182,6 +182,13 @@ public static String getCurrentTimeStamp() { return df.format(new Date()); } + public static String getCurrentMilliSecondUTCTimeStamp() { + @SuppressLint("SimpleDateFormat") + final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z"); + df.setTimeZone(TimeZone.getTimeZone("UTC")); + return df.format(new Date()); + } + public static String getCurrentMilliSecondLocalTimeStamp() { @SuppressLint("SimpleDateFormat") final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss.SSS");