/** * Convert date to a date object * * @param date as a string 2015-03-02T09:07:00.000Z * @return date */ public static Date getDateFromString(String date) { SimpleDateFormat formatter = new SimpleDateFormat(JSON_DATE_FORMAT); try { return formatter.parse(date); } catch (ParseException e) { Utils.log(e.getMessage()); return null; } }
/** * @param url the URL to get from * @param getData the raw string to send as the payload */ public static String httpGet(String url, String getData) { StringBuilder builder = new StringBuilder(); try { HttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url + "?" + getData); httpGet.setHeader("Accept", "application/json"); HttpResponse response = client.execute(httpGet); HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; while ((line = reader.readLine()) != null) { builder.append(line); } } catch (IOException e) { Utils.log(e.getMessage()); } return builder.toString(); }