diff options
author | Camil Staps | 2015-04-15 22:56:54 +0200 |
---|---|---|
committer | Camil Staps | 2015-04-15 22:56:54 +0200 |
commit | 1c677db0d57b62d03df92a4e19e8316c878170d8 (patch) | |
tree | 7b0f3e2b7cae49c4e4aa99109668ebaff1071181 /app | |
parent | javadoc Date (diff) |
javadoc DatedString
Diffstat (limited to 'app')
-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 { |