aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-06-26 17:37:44 -0700
committerScott Jackson <daneren2005@gmail.com>2015-06-26 17:37:44 -0700
commita3f294cd6773585fa59753e25101e4029004495f (patch)
tree54a72d1ec9e064642ee691aa75e476da035b988d
parentfa3746db84c2afd4d7f3edb2c5728e2c9cf27a7b (diff)
downloaddsub-a3f294cd6773585fa59753e25101e4029004495f.tar.gz
dsub-a3f294cd6773585fa59753e25101e4029004495f.tar.bz2
dsub-a3f294cd6773585fa59753e25101e4029004495f.zip
Format playlist creation date
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Util.java16
2 files changed, 17 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
index 7a4c708e..5b7e68a6 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
@@ -217,7 +217,7 @@ public class SelectPlaylistFragment extends SelectRecyclerFragment<Playlist> {
((playlist.getComment() == null) ? "" : playlist.getComment()) +
"\nSong Count: " + playlist.getSongCount() +
((playlist.getPublic() == null) ? "" : ("\nPublic: " + playlist.getPublic())) +
- "\nCreation Date: " + playlist.getCreated().replace('T', ' ');
+ "\nCreated: " + Util.formatDate(context, playlist.getCreated());
Util.info(context, playlist.getName(), message);
}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java
index f44bc672..a3728d29 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Util.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java
@@ -53,6 +53,7 @@ import github.daneren2005.dsub.activity.SubsonicFragmentActivity;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PlayerState;
import github.daneren2005.dsub.domain.RepeatMode;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.receiver.MediaButtonIntentReceiver;
import github.daneren2005.dsub.service.DownloadService;
@@ -70,10 +71,12 @@ import java.lang.reflect.Method;
import java.security.MessageDigest;
import java.text.DecimalFormat;
import java.text.NumberFormat;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
+import java.util.TimeZone;
/**
* @author Sindre Mehus
@@ -829,6 +832,19 @@ public final class Util {
return builder.toString();
}
+ public static String formatDate(Context context, String dateString) {
+ try {
+ boolean isDateNormalized = ServerInfo.checkServerVersion(context, "1.11");
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH);
+ if (isDateNormalized) {
+ dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ }
+
+ return formatDate(dateFormat.parse(dateString));
+ } catch(ParseException e) {
+ return dateString;
+ }
+ }
public static String formatDate(Date date) {
if(date == null) {
return "Never";