package api.jisuapi.huangli; import api.util.HttpUtil; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class Date { public static final String APPKEY = "your_appkey_here";// 你的appkey public static final String URL = "https://api.jisuapi.com/huangli/date"; public static final String year = "2015"; public static final String month = "10"; public static final String day = "27"; public static void Get() { String result = null; String url = URL + "?appkey=" + APPKEY + "&year=" + year + "&month=" + month + "&day=" + day; try { result = HttpUtil.sendGet(url, "utf-8"); JSONObject json = JSONObject.fromObject(result); if (json.getInt("status") != 0) { System.out.println(json.getString("msg")); } else { JSONObject resultarr = json.optJSONObject("result"); String year = resultarr.getString("year"); String month = resultarr.getString("month"); String day = resultarr.getString("day"); String yangli = resultarr.getString("yangli"); String nongli = resultarr.getString("nongli"); String star = resultarr.getString("star"); String taishen = resultarr.getString("taishen"); String wuxing = resultarr.getString("wuxing"); String chong = resultarr.getString("chong"); String sha = resultarr.getString("sha"); String shengxiao = resultarr.getString("shengxiao"); String jiri = resultarr.getString("jiri"); String zhiri = resultarr.getString("zhiri"); String xiongshen = resultarr.getString("xiongshen"); String jishenyiqu = resultarr.getString("jishenyiqu"); String caishen = resultarr.getString("caishen"); String xishen = resultarr.getString("xishen"); String fushen = resultarr.getString("fushen"); System.out.println(year + " " + month + " " + day + " " + yangli + " " + nongli + " " + star + " " + taishen + " " + wuxing + " " + chong + " " + sha + " " + shengxiao + " " + jiri + " " + zhiri + " " + xiongshen + " " + jishenyiqu + " " + caishen + " " + xishen + " " + fushen); JSONArray suici = resultarr.optJSONArray("suici"); for (int i = 0; i < suici.size(); i++) { System.out.print(suici.get(i) + " "); } System.out.println(); JSONArray yi = resultarr.optJSONArray("yi"); for (int i = 0; i < yi.size(); i++) { System.out.print(yi.get(i) + " "); } System.out.println(); JSONArray ji = resultarr.optJSONArray("ji"); for (int i = 0; i < ji.size(); i++) { System.out.print(ji.get(i) + " "); } System.out.println(); String eweek = resultarr.getString("eweek"); String emonth = resultarr.getString("emonth"); String week = resultarr.getString("week"); System.out.println(eweek + " " + emonth + " " + week); } } catch (Exception e) { e.printStackTrace(); } } }