From 1c677db0d57b62d03df92a4e19e8316c878170d8 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 15 Apr 2015 22:56:54 +0200 Subject: javadoc DatedString --- app/src/main/java/com/camilstaps/common/DatedString.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'app/src') 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 { -- cgit v1.2.3