获取多天数据并组装成自己需要的数据

// 设置日期列表
			Date today = new Date();

			// 获取三天影片列表
			for (int i = 0; i < movieKeepDays; i++) {
				String date = DateUtil.format(DateUtil.addDay(today, i), "yyyyMMdd");
				log.info("获取影片列表开始,日期:" + date);
				String content = StringUtil.joinXmlStartElement("data");
				content += StringUtil.joinXmlResultElement();

				List movieList = dataCache.getMovieList(date);

				// 循环获取影院列表
				for (Object object : movieList) {
					Movie movie = (Movie) object;
					List cinemaList = dataCache.getCinemaList(date, movie.getMovieid());
					if (null != cinemaList && cinemaList.size() > 0) {
						for (Object object2 : cinemaList) {
							Cinema cinema = (Cinema) object2;
							log.info("影院详情,Cinemaid:" + cinema.getCinemaid());
							if (cinema != null) {
								content += StringUtil.joinXmlStartElement("cinema");

								content += StringUtil.joinXmlElement("cinemaid", cinema.getCinemaid());
								content += StringUtil.joinXmlElement("cinemaname", cinema.getCinemaname());
								content += StringUtil.joinXmlElement("address", cinema.getAddress(), true);
								content += StringUtil.joinXmlElement("transport", cinema.getTransport(), true);
								content += StringUtil.joinXmlElement("content", cinema.getContent(), true);
								content += StringUtil.joinXmlElement("countycode", cinema.getCountycode(), true);
								content += StringUtil.joinXmlElement("countyname", cinema.getCountyname(), true);

								content += StringUtil.joinXmlEndElement("cinema");
								content += "\n";
							}
						}
					} else {
						notFoundService("07", response);
					}
				}
				content += StringUtil.joinXmlEndElement("data");
				printXmlContent(content, response);
			}


public static final <T extends Date> T addDay(T original, int days) {
		if (original == null) return null;
		long newTime = original.getTime() + m_day * days;
		T another = (T) original.clone();
		another.setTime(newTime);
		return another;
	}

你可能感兴趣的:(java,Date,foreach,format)