Use ISO date-time formatter (#954)

This commit is contained in:
vvb2060 2021-08-20 02:55:52 +08:00 committed by GitHub
parent 5af017dc32
commit 7ef5da6867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

View File

@ -36,8 +36,7 @@ import org.lsposed.manager.BuildConfig;
import org.lsposed.manager.R; import org.lsposed.manager.R;
import org.lsposed.manager.databinding.ActivityCrashReportBinding; import org.lsposed.manager.databinding.ActivityCrashReportBinding;
import java.time.Instant; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class CrashReportActivity extends AppCompatActivity { public class CrashReportActivity extends AppCompatActivity {
ActivityCrashReportBinding binding; ActivityCrashReportBinding binding;
@ -60,11 +59,10 @@ public class CrashReportActivity extends AppCompatActivity {
} }
public String getAllErrorDetailsFromIntent(@NonNull Intent intent) { public String getAllErrorDetailsFromIntent(@NonNull Intent intent) {
var dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
String versionName = String.format("%s (%s)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE); String versionName = String.format("%s (%s)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
return "Build version: " + versionName + " \n" + return "Build version: " + versionName + " \n" +
"Current date: " + dateFormat.format(Instant.now()) + " \n" + "Current date: " + LocalDateTime.now() + " \n" +
"Device: " + getDeviceModelName() + " \n" + "Device: " + getDeviceModelName() + " \n" +
"Fingerprint: " + getFingerprint() + " \n \n" + "Fingerprint: " + getFingerprint() + " \n \n" +
"SDK: " + Build.VERSION.SDK_INT + " \n \n" + "SDK: " + Build.VERSION.SDK_INT + " \n \n" +

View File

@ -30,7 +30,6 @@ import java.io.IOException;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Locale;
public class ModuleLogger { public class ModuleLogger {
private static DateTimeFormatter logDateFormat; private static DateTimeFormatter logDateFormat;
@ -39,9 +38,8 @@ public class ModuleLogger {
public static void initLogger(ParcelFileDescriptor fileDescriptor) { public static void initLogger(ParcelFileDescriptor fileDescriptor) {
if (fd == null && fileDescriptor != null) { if (fd == null && fileDescriptor != null) {
fd = fileDescriptor; fd = fileDescriptor;
var zone = ZoneId.of(SystemProperties.get("persist.sys.timezone")); var zone = ZoneId.of(SystemProperties.get("persist.sys.timezone", "GMT"));
var pattern = "yyyy-MM-dd HH:mm:ss.SSS"; logDateFormat = DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(zone);
logDateFormat = DateTimeFormatter.ofPattern(pattern, Locale.ROOT).withZone(zone);
} }
} }

View File

@ -1,11 +1,18 @@
package android.os; package android.os;
import android.annotation.NonNull;
import android.annotation.Nullable;
public class SystemProperties { public class SystemProperties {
public static String get(String key) { public static String get(@NonNull String key) {
throw new UnsupportedOperationException("Stub"); throw new UnsupportedOperationException("Stub");
} }
public static void set(String key, String val) { public static String get(@NonNull String key, @Nullable String def) {
throw new UnsupportedOperationException("Stub");
}
public static void set(@NonNull String key, @Nullable String val) {
throw new UnsupportedOperationException("Stub"); throw new UnsupportedOperationException("Stub");
} }
} }