你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:杂志经典 / 网络与通信
用Java实现Yahoo天气预报客户端(十一)
 

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+"公里");

//解析天文学有关信息

  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089