📄 weatherforecastservice.java
字号:
package ajaxdashboard.service;import ajaxdashboard.ws.weatherforecast.WeatherData;import ajaxdashboard.ws.weatherforecast.WeatherForecast;import ajaxdashboard.ws.weatherforecast.WeatherForecastLocator;import ajaxdashboard.ws.weatherforecast.WeatherForecastSoap;import ajaxdashboard.ws.weatherforecast.WeatherForecasts;import java.text.SimpleDateFormat;import javax.xml.rpc.ServiceException;public class WeatherForecastService { public WeatherForecasts getForecastFor(String zipCode) { WeatherForecasts forecasts = null; try { forecasts = getWeatherForecastSoap().getWeatherByZipCode(zipCode); WeatherData[] dataArray = forecasts.getDetails().getWeatherData(); WeatherData data = null; SimpleDateFormat parser = new SimpleDateFormat("EEEE, MMMM dd, yyyy"); SimpleDateFormat formatter = new SimpleDateFormat("EEE. MM/dd"); for(int i = 0; i < dataArray.length; i++) { data = dataArray[i]; try { data.setDay(formatter.format(parser.parse(data.getDay()))); } catch(Exception e) { System.out.println("\n\n\nParsing Exception: " + e); } } } catch(java.rmi.RemoteException ex) { // TODO handle remote exception } return forecasts; } private WeatherForecastSoap getWeatherForecastSoap() { WeatherForecastSoap weatherForecastSoap = null; try { weatherForecastSoap = new WeatherForecastLocator().getWeatherForecastSoap(); } catch (ServiceException ex) { ex.printStackTrace(); } return weatherForecastSoap; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -