aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils/Formatter.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/utils/Formatter.java')
-rw-r--r--main/src/cgeo/geocaching/utils/Formatter.java24
1 files changed, 18 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/utils/Formatter.java b/main/src/cgeo/geocaching/utils/Formatter.java
index c764c5a..2127d59 100644
--- a/main/src/cgeo/geocaching/utils/Formatter.java
+++ b/main/src/cgeo/geocaching/utils/Formatter.java
@@ -17,6 +17,7 @@ import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Locale;
public abstract class Formatter {
@@ -76,6 +77,10 @@ public abstract class Formatter {
return dateFormat.format(date);
}
+ private static String formatShortDateIncludingWeekday(final long time) {
+ return DateUtils.formatDateTime(CgeoApplication.getInstance().getBaseContext(), time, DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY) + ", " + formatShortDate(time);
+ }
+
/**
* Generate a numeric date string according to system-wide settings (locale, date format)
* such as "10/20/2010". Today and yesterday will be presented as strings "today" and "yesterday".
@@ -85,7 +90,7 @@ public abstract class Formatter {
* @return the formatted string
*/
public static String formatShortDateVerbally(final long date) {
- final int diff = cgeo.geocaching.utils.DateUtils.daysSince(date);
+ final int diff = CalendarUtils.daysSince(date);
switch (diff) {
case 0:
return CgeoApplication.getInstance().getString(R.string.log_today);
@@ -145,10 +150,10 @@ public abstract class Formatter {
private static void addShortInfos(final Geocache cache, final ArrayList<String> infos) {
if (cache.hasDifficulty()) {
- infos.add("D " + String.format("%.1f", cache.getDifficulty()));
+ infos.add("D " + formatDT(cache.getDifficulty()));
}
if (cache.hasTerrain()) {
- infos.add("T " + String.format("%.1f", cache.getTerrain()));
+ infos.add("T " + formatDT(cache.getTerrain()));
}
// don't show "not chosen" for events and virtuals, that should be the normal case
@@ -157,11 +162,15 @@ public abstract class Formatter {
} else if (cache.isEventCache()) {
final Date hiddenDate = cache.getHiddenDate();
if (hiddenDate != null) {
- infos.add(Formatter.formatShortDate(hiddenDate.getTime()));
+ infos.add(Formatter.formatShortDateIncludingWeekday(hiddenDate.getTime()));
}
}
}
+ private static String formatDT(final float value) {
+ return String.format(Locale.getDefault(), "%.1f", value);
+ }
+
public static String formatCacheInfoHistory(final Geocache cache) {
final ArrayList<String> infos = new ArrayList<>(3);
infos.add(StringUtils.upperCase(cache.getGeocode()));
@@ -190,7 +199,7 @@ public abstract class Formatter {
}
public static String formatDaysAgo(final long date) {
- final int days = cgeo.geocaching.utils.DateUtils.daysSince(date);
+ final int days = CalendarUtils.daysSince(date);
switch (days) {
case 0:
return CgeoApplication.getInstance().getString(R.string.log_today);
@@ -204,7 +213,6 @@ public abstract class Formatter {
/**
* Formatting of the hidden date of a cache
*
- * @param cache
* @return {@code null} or hidden date of the cache (or event date of the cache) in human readable format
*/
public static String formatHiddenDate(final Geocache cache) {
@@ -223,4 +231,8 @@ public abstract class Formatter {
return dateString;
}
+ public static String formatMapSubtitle(final Geocache cache) {
+ return "D " + formatDT(cache.getDifficulty()) + SEPARATOR + "T " + formatDT(cache.getTerrain()) + SEPARATOR + cache.getGeocode();
+ }
+
}