From f6d191e4e1278a62086ac25a04e6a2c218c4670d Mon Sep 17 00:00:00 2001 From: Nikunj-Aggarwal Date: Wed, 8 Jan 2025 00:14:35 +0530 Subject: [PATCH] feat: added DateTimeHelper to convert current date in ISO format --- .../schabi/newpipe/error/ErrorActivity.java | 4 ++-- .../schabi/newpipe/util/DateTimeHelper.java | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/util/DateTimeHelper.java diff --git a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java index 2f607b4876a..9445c53fd41 100644 --- a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java @@ -22,11 +22,11 @@ import org.schabi.newpipe.BuildConfig; import org.schabi.newpipe.R; import org.schabi.newpipe.databinding.ActivityErrorBinding; +import org.schabi.newpipe.util.DateTimeHelper; import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.util.external_communication.ShareUtils; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.stream.Collectors; @@ -107,7 +107,7 @@ protected void onCreate(final Bundle savedInstanceState) { // important add guru meditation addGuruMeditation(); - currentTimeStamp = CURRENT_TIMESTAMP_FORMATTER.format(LocalDateTime.now()); + currentTimeStamp = DateTimeHelper.currentDateToIsoDateFormat(); activityErrorBinding.errorReportEmailButton.setOnClickListener(v -> openPrivacyPolicyDialog(this, "EMAIL")); diff --git a/app/src/main/java/org/schabi/newpipe/util/DateTimeHelper.java b/app/src/main/java/org/schabi/newpipe/util/DateTimeHelper.java new file mode 100644 index 00000000000..ae1f2e94c1b --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/util/DateTimeHelper.java @@ -0,0 +1,20 @@ +package org.schabi.newpipe.util; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public final class DateTimeHelper { + private static final String TAG = DateTimeHelper.class.getSimpleName(); + + private DateTimeHelper() { + //no instance + } + + /** + * @return the current date in ISO format. + */ + public static String currentDateToIsoDateFormat() { + final LocalDateTime currentDate = LocalDateTime.now(); + return currentDate.format(DateTimeFormatter.ISO_DATE_TIME); + } +}