Source:
public void fetchBudgetsAndEntries(final ApiCallback<List<Budget>> callback) { Log.d(TAG, "Fetching all budgets and entries"); client.get(budgetsAndEntriesUrl, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONArray budgetsJson) { List<Budget> budgetList = new ArrayList<Budget>(); int budgetsLen = budgetsJson.length(); for (int i = 0; i < budgetsLen; ++i) { try { JSONObject budgetObject = budgetsJson.getJSONObject(i); String budgetName = budgetObject.getString("budget_name"); String duration = budgetObject.getString("recurrence_duration"); int amount = budgetObject.getInt("amount"); int currentAmount = budgetObject.optInt("amount_so_far"); int otherDuration = budgetObject.optInt("other_duration"); boolean recur = budgetObject.optBoolean("recur"); long startDate = dateToMilliseconds( budgetObject.getString("start_date")); long id = budgetObject.getLong("id"); Budget newBudget = new Budget(budgetName, amount, currentAmount, recur, startDate, duration, otherDuration); newBudget.setId(id); JSONArray entriesJson = budgetObject.getJSONArray("entries"); int entriesLen = entriesJson.length(); for (int j = 0; j < entriesLen; j++) { JSONObject entriesObject = entriesJson.getJSONObject(i); long entryId = entriesObject.getLong("id"); int entryAmount = entriesObject.getInt("amount"); String entryDate = entriesObject.getString("expenditure_date"); String entryNotes = entriesObject.getString("notes"); Entry newEntry = new Entry(entryId, entryAmount, newBudget, entryNotes, entryDate); newBudget.addEntry(newEntry); } budgetList.add(newBudget); } catch (JSONException e) { Log.e(TAG, e.getMessage()); } } callback.onSuccess(budgetList); } @Override public void onFailure(Throwable e, JSONObject obj) { String status = obj.optString("status", "Service Error"); callback.onFailure(status); } }); }

Target:
public void fetchBudgetsAndEntries(final ApiCallback<List<Budget>> callback) { Log.d(TAG, "Fetching all budgets and entries"); client.get(budgetsAndEntriesUrl, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONArray budgetsJson) { List<Budget> budgetList = new ArrayList<Budget>(); int budgetsLen = budgetsJson.length(); for (int i = 0; i < budgetsLen; ++i) { try { JSONObject budgetObject = budgetsJson.getJSONObject(i); String budgetName = budgetObject.getString("budget_name"); String duration = budgetObject.getString("recurrence_duration"); int amount = budgetObject.getInt("amount"); boolean recur = budgetObject.optBoolean("recur"); LocalDate startDate = LocalDate.parse(budgetObject.getString("start_date"), DateTimeFormat.forPattern("yyyy-MM-dd")); long id = budgetObject.getLong("id"); Budget newBudget = new Budget(budgetName, amount, recur, startDate, Duration.valueOf(duration)); newBudget.setId(id); JSONArray entriesJson = budgetObject.getJSONArray("entries"); int entriesLen = entriesJson.length(); for (int j = 0; j < entriesLen; j++) { JSONObject entriesObject = entriesJson.getJSONObject(i); long entryId = entriesObject.getLong("id"); int entryAmount = entriesObject.getInt("amount"); String entryDate = entriesObject.getString("expenditure_date"); String entryNotes = entriesObject.getString("notes"); Entry newEntry = new Entry(entryId, entryAmount, newBudget, entryNotes, entryDate); newBudget.addEntry(newEntry); } budgetList.add(newBudget); } catch (JSONException e) { Log.e(TAG, e.getMessage()); } } callback.onSuccess(budgetList); } @Override public void onFailure(Throwable e, JSONObject obj) { String status = obj.optString("status", "Service Error"); callback.onFailure(status); } }); }