package com.rthoni.stssaguenay.dbo; import com.luticate.utils.dbo.LuDbo; import com.luticate.utils.dbo.LuPaginatedDbo; import org.joda.time.LocalDateTime; import org.joda.time.LocalTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.HashMap; import java.util.List; import java.util.Vector; /** * Created by robin on 10/1/16. */ public class SchedulesDbo extends LuDbo { public static class SchedulesDboArray extends LuPaginatedDbo { } protected String _stopId; protected String _routeId; protected List _schedules; @Override public void fromJson(JSONObject json) throws JSONException { _stopId = json.getString("stopId"); _routeId = json.getString("routeId"); _schedules = new Vector<>(); JSONArray schedules = json.getJSONArray("schedules"); for (int i = 0; i < schedules.length(); ++i) { _schedules.add(LocalDateTime.parse(schedules.getString(i), DateTimeFormat.forPattern("y-M-d H:m:s"))); } } @Override public HashMap toArray() { return null; } public String getStopId() { return _stopId; } public void setStopId(String stopId) { _stopId = stopId; } public String getRouteId() { return _routeId; } public void setRouteId(String routeId) { _routeId = routeId; } public List getSchedules() { return _schedules; } public void setSchedules(List schedules) { _schedules = schedules; } }