public UserEntry(final JSONObject json) { this.map = new LinkedHashMap<String, Object>(); Iterator<String> ki = json.keys(); while (ki.hasNext()) { String key = ki.next(); try { Object val = json.get(key); this.map.put(key, val); } catch (JSONException e) { } } Date now = new Date(); map.put( UserFactory.field_appearance_first, parseDate(map.get(UserFactory.field_appearance_first), now)); map.put( UserFactory.field_appearance_latest, parseDate(map.get(UserFactory.field_appearance_latest), now)); }
public JSONObject toJSON() throws JSONException { JSONObject json = new JSONObject(); json.put(UserFactory.field_screen_name, getScreenName()); json.put(UserFactory.field_user_id, getUserId()); json.put(UserFactory.field_name, getName()); if (this.map.containsKey(UserFactory.field_profile_image_url_http)) json.put( UserFactory.field_profile_image_url_http, this.map.get(UserFactory.field_profile_image_url_http)); if (this.map.containsKey(UserFactory.field_profile_image_url_https)) json.put( UserFactory.field_profile_image_url_https, this.map.get(UserFactory.field_profile_image_url_https)); json.put( UserFactory.field_appearance_first, utcFormatter.print(getAppearanceFirst().getTime())); json.put( UserFactory.field_appearance_latest, utcFormatter.print(getAppearanceLatest().getTime())); if (this.map.containsKey(UserFactory.field_profile_image)) json.put(UserFactory.field_profile_image, this.map.get(UserFactory.field_profile_image)); return json; }