就是微信小程序获取数据中实时分析,一直报日期格式错误
发布于 6 年前 作者 zgao 5653 次浏览 来自 问答

String grant_type = “client_credential”;

String url = “https://api.weixin.qq.com/cgi-bin/token”;

String param = “grant_type=”+grant_type+"&appid="+appid+"&secret="+appSecret;

String access_token = HttpRequest.sendGet(url, param);

Map<String,Object> map = JSON.parseObject(access_token);

System.out.println("—"+map.get(“access_token”));

String begin_date = new SimpleDateFormat(“yyyyMMdd”).format(new Date());

System.out.println(“date===:”+begin_date);

Calendar ca = Calendar.getInstance();//得到一个Calendar的实例 

ca.setTime(new Date()); //设置时间为当前时间

ca.add(Calendar.DATE, -1);

Date lastMonth = ca.getTime();

String end_date = new SimpleDateFormat(“yyyyMMdd”).format(lastMonth);

System.out.println(“end_date===:”+end_date);

 

String url1 = “https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token=”+map.get(“access_token”);

String param1 = “&end_date=20170313&begin_date=20170313”;

String JsonList = HttpRequest.sendPost(url1, param1);

System.out.println(JsonList);

报:{“errcode”:61500,“errmsg”:“date format error hint: [x9JRTA02761556]”}

回到顶部