NodeList links =
doc.getElementsByTagName("pubDate");
String dateStr =
links.item(0).getFirstChild().getNodeValue();
SimpleDateFormat sdf=new SimpleDateFormat(
"EEE, dd MMM yyyy K:mm aa zzz",Locale.US);
Date date=sdf.parse(dateStr);
Calendar cd=Calendar.getInstance();
cd.setTime(date);
dateStr=(cd.get(Calendar.YEAR))+"年"
+(cd.get(Calendar.MONTH)+1)+"月"
+(cd.get(Calendar.DATE))+"日"
+cd.get(Calendar.HOUR_OF_DAY)+"时"
+((cd.get(Calendar.MINUTE)>9)?cd.get(Calendar.MINUTE)+"":"0"+cd.get(Calendar.MINUTE))+"分";
ywf.jlTodayPublishTime.setText(
"发布时间:"+dateStr);
//解析风相关信息
links =doc.getElementsByTagName("yweather:wind");
NamedNodeMap nnm=links.item(0).getAttributes();
ywf.jlTodayChill.setText("风冷热系数:"
+nnm.getNamedItem("chill").getNodeValue());
ywf.jlTodaySpeed.setText("风速:"
+nnm.getNamedItem("speed").getNodeValue()
+"公里/小时");
String directionStr=
nnm.getNamedItem("direction").getNodeValue();
int directionInt=Integer.parseInt(directionStr);
ywf.jlTodayDirection.setText("风向:"
+fromDegreeToDirectionStr(directionInt));
//解析大气相关信息
links =doc.getElementsByTagName(
"yweather:atmosphere");
nnm=links.item(0).getAttributes();
ywf.jlTodayHumidity.setText("湿度:"+
nnm.getNamedItem("humidity").getNodeValue()+"%");
ywf.jlTodayPressure.setText("气压:"+
nnm.getNamedItem("pressure").getNodeValue()+"毫巴");
ywf.jlTodayVisibility.setText("能见度:"+
((int)Double.parseDouble(nnm.getNamedItem("visibility").getNodeValue())*100)/10000.0+"公里");
//解析天文学有关信息
|