public static String listMessageCounterHistory(final MessageCounter counter) throws Exception { List<DayCounter> history = counter.getHistory(); DayCounterInfo[] infos = new DayCounterInfo[history.size()]; for (int i = 0; i < infos.length; i++) { DayCounter dayCounter = history.get(i); int[] counters = dayCounter.getCounters(); GregorianCalendar date = dayCounter.getDate(); DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT); String strData = dateFormat.format(date.getTime()); infos[i] = new DayCounterInfo(strData, counters); } return DayCounterInfo.toJSON(infos); }
public static String listMessageCounterHistory(final MessageCounter counter) throws Exception { List<DayCounter> history = counter.getHistory(); DayCounterInfo[] infos = new DayCounterInfo[history.size()]; for (int i = 0; i < infos.length; i++) { DayCounter dayCounter = history.get(i); int[] counters = dayCounter.getCounters(); GregorianCalendar date = dayCounter.getDate(); DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT); String strData = dateFormat.format(date.getTime()); infos[i] = new DayCounterInfo(strData, counters); } return DayCounterInfo.toJSON(infos); }
/** * Returns an array of RoleInfo corresponding to the JSON serialization returned * by {@link QueueControl#listMessageCounterHistory()}. */ public static DayCounterInfo[] fromJSON(final String jsonString) throws JSONException { JSONObject json = new JSONObject(jsonString); JSONArray dayCounters = json.getJSONArray("dayCounters"); DayCounterInfo[] infos = new DayCounterInfo[dayCounters.length()]; for (int i = 0; i < dayCounters.length(); i++) { JSONObject counter = (JSONObject)dayCounters.get(i); JSONArray hour = (JSONArray)counter.getJSONArray("counters").get(0); int[] hourCounters = new int[24]; for (int j = 0; j < 24; j++) { hourCounters[j] = hour.getInt(j); } DayCounterInfo info = new DayCounterInfo(counter.getString("date"), hourCounters); infos[i] = info; } return infos; }
/** * Returns an array of RoleInfo corresponding to the JSON serialization returned * by {@link QueueControl#listMessageCounterHistory()}. */ public static DayCounterInfo[] fromJSON(final String jsonString) throws JSONException { JSONObject json = new JSONObject(jsonString); JSONArray dayCounters = json.getJSONArray("dayCounters"); DayCounterInfo[] infos = new DayCounterInfo[dayCounters.length()]; for (int i = 0; i < dayCounters.length(); i++) { JSONObject counter = (JSONObject)dayCounters.get(i); JSONArray hour = (JSONArray)counter.getJSONArray("counters").get(0); int[] hourCounters = new int[24]; for (int j = 0; j < 24; j++) { hourCounters[j] = hour.getInt(j); } DayCounterInfo info = new DayCounterInfo(counter.getString("date"), hourCounters); infos[i] = info; } return infos; }