diff options
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/com/camilstaps/common/DatedString.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/src/main/java/com/camilstaps/common/DatedString.java b/app/src/main/java/com/camilstaps/common/DatedString.java index a452ab0..c1027ae 100644 --- a/app/src/main/java/com/camilstaps/common/DatedString.java +++ b/app/src/main/java/com/camilstaps/common/DatedString.java @@ -7,7 +7,8 @@ import java.lang.reflect.InvocationTargetException; import java.text.ParseException; /** - * Created by camilstaps on 11-4-15. + * DatedString: a Date - String pair + * @author Camil Staps */ public class DatedString { @@ -27,6 +28,10 @@ public class DatedString { return date; } + /** + * JSON-encode the pair so that it can be stored in SharedPreferences, for example + * @return + */ @Override public String toString() { JSONObject json = new JSONObject(); @@ -37,6 +42,14 @@ public class DatedString { return json.toString(); } + /** + * JSON-decode some encoded pair + * @param s the String to decode + * @param castTo the specific class to cast to (may be DatedString or one of its children) + * @return + * @throws JSONException if the String was no valid JSON + * @throws ParseException if the date in the JSON was no valid Date + */ public static Object fromString(String s, Class castTo) throws JSONException, ParseException { JSONObject json = new JSONObject(s); try { |