summaryrefslogtreecommitdiffstats
path: root/src/com/android/wallpaper/util/TimeUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/wallpaper/util/TimeUtils.java')
-rw-r--r--src/com/android/wallpaper/util/TimeUtils.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/com/android/wallpaper/util/TimeUtils.java b/src/com/android/wallpaper/util/TimeUtils.java
index 5b3334c..2dc9f51 100644
--- a/src/com/android/wallpaper/util/TimeUtils.java
+++ b/src/com/android/wallpaper/util/TimeUtils.java
@@ -26,12 +26,18 @@ import androidx.annotation.Nullable;
import java.util.Calendar;
/** Utility class for clock time preview. */
-public class TimeUtils {
+public final class TimeUtils {
- private static final String CLOCK_FORMAT_12HOUR = "h:mm";
- private static final String CLOCK_FORMAT_24HOUR = "H:mm";
+ private static final CharSequence CLOCK_FORMAT_12HOUR = "h:mm";
+ private static final CharSequence CLOCK_FORMAT_24HOUR = "H:mm";
+ private static final CharSequence CLOCK_DOUBLE_LINE_FORMAT_12_HOUR = "hh\nmm";
+ private static final CharSequence CLOCK_DOUBLE_LINE_FORMAT_24_HOUR = "HH\nmm";
- /** Returns the clock formatted time. For 12-hour format, there's no AM/PM field displayed. */
+ /**
+ * Returns the default clock formatted time. For example: 4:35 or 16:35.
+ *
+ * <p> For 12-hour format, there's no AM/PM field displayed.
+ */
public static CharSequence getFormattedTime(Context context, Calendar calendar) {
return DateFormat.format(
DateFormat.is24HourFormat(context)
@@ -41,6 +47,20 @@ public class TimeUtils {
}
/**
+ * Returns the double line clock formatted time.
+ *
+ * <p> For 12-hour format, there's no AM/PM field displayed.
+ */
+ public static CharSequence getDoubleLineFormattedTime(Context context,
+ Calendar calendar) {
+ return DateFormat.format(
+ DateFormat.is24HourFormat(context)
+ ? CLOCK_DOUBLE_LINE_FORMAT_24_HOUR
+ : CLOCK_DOUBLE_LINE_FORMAT_12_HOUR,
+ calendar);
+ }
+
+ /**
* BroadcastReceiver that can notify a listener when the system time (minutes) changes.
* Use {@link #registerNewReceiver(Context, TimeListener)} to create a new instance that will be
* automatically registered using the given Context.