瀏覽代碼

Merge branch 'master' of shikejing/guns-separation into master

shikejing 4 年之前
父節點
當前提交
de2c42f002

+ 1 - 40
guns-main/pom.xml

@ -4,45 +4,6 @@
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <properties>
        <version.springside>4.2.3-GA</version.springside>
        <version.swagger>2.7.0</version.swagger>
        <version.poi>3.15-beta1</version.poi>
        <version.hibernate>4.3.5.Final</version.hibernate>
        <version.hibernate-validator>5.0.3.Final</version.hibernate-validator>
        <version.logback>1.2.3</version.logback>
        <version.aspectj>1.7.4</version.aspectj>
        <version.quartz>2.2.3</version.quartz>
        <version.fastdfs>1.25</version.fastdfs>
        <version.joda-time>2.8.2</version.joda-time>
        <version.kaptcha>2.3</version.kaptcha>
        <version.orgjson>20160212</version.orgjson>
        <version.htmlparser>2.1</version.htmlparser>
        <version.xom>1.1</version.xom>
        <version.xstream>1.4.7</version.xstream>
        <version.zxing>3.2.0</version.zxing>
        <version.fastdfs>1.2.17</version.fastdfs>
        <version.ylz>1.0.0</version.ylz>
        <version.ylz.ehc>1.0.0.20171025</version.ylz.ehc>
        <version.elasticsearch>2.4.4</version.elasticsearch>
        <version.jest>2.4.0</version.jest>
        <sitemesh.version>2.4.2</sitemesh.version>
        <slf4j.version>1.7.7</slf4j.version>
        <commons-lang3.version>3.3.2</commons-lang3.version>
        <guava.version>18.0</guava.version>
        <assertj.version>1.6.1</assertj.version>
        <mockito.version>1.9.5</mockito.version>
        <selenium.version>2.42.2</selenium.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <version.mysql>5.1.38</version.mysql>
        <version.activemq>5.15.0</version.activemq>
        <version.common>1.0.0</version.common>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <asciidoctor.maven.plugin.version>1.5.5</asciidoctor.maven.plugin.version>
        <asciidoctorj.version>1.5.5</asciidoctorj.version>
        <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
    </properties>
    <parent>
        <groupId>cn.stylefeng</groupId>
        <artifactId>guns-separation</artifactId>
@ -71,7 +32,7 @@
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>${version.orgjson}</version>
            <version>20160212</version>
        </dependency>
        <dependency>

+ 17 - 5
guns-main/src/main/java/cn/stylefeng/guns/zjxl/cnotroller/ZjxlBannerCnotroller.java

@ -5,6 +5,7 @@ import cn.stylefeng.guns.zjxl.model.ZjxlCompanyCase;
import cn.stylefeng.guns.zjxl.model.ret.BannerCompanyCaseRet;
import cn.stylefeng.guns.zjxl.service.ZjxlBannerService;
import cn.stylefeng.guns.zjxl.service.ZjxlCompanyCaseService;
import cn.stylefeng.guns.zjxlUtil.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -24,7 +25,7 @@ import java.util.Optional;
@RestController
@Api(description = "公司官网主页")
@RequestMapping(value = "/zjxl")
public class ZjxlBannerCnotroller {
public class ZjxlBannerCnotroller extends BaseController {
    @Autowired
    private ZjxlBannerService bannerService;
@ -34,14 +35,25 @@ public class ZjxlBannerCnotroller {
    @RequestMapping(value = "/findBannerById", method = RequestMethod.GET)
    @ApiOperation(value = "根据Id查看banner")
    public ZjxlBanner findBannerById(String id){
        return bannerService.findById(id);
    public String findBannerById(String id){
        try {
            ZjxlBanner banner = bannerService.findById(id);
            return write(200,"查询成功","data",banner);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/findCompanyCaseById", method = RequestMethod.GET)
    @ApiOperation(value = "根据Id查看CompanyCase")
    public ZjxlCompanyCase findCompanyCaseById(String id){
        return companyCaseService.findById(id);
    public String findCompanyCaseById(String id){
        try {
            return write(200,"查询成功","data",companyCaseService.findById(id));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/finfBannerCompanyCaseById", method = RequestMethod.GET)

+ 74 - 890
guns-main/src/main/java/cn/stylefeng/guns/zjxlUtil/DateUtil.java

@ -1,88 +1,35 @@
package cn.stylefeng.guns.zjxlUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
public class
DateUtil {
public class DateUtil {
	public static final String HH_MM = "HH:mm";
	public static final String HH_MM_SS = "HH:mm:ss";
	public static final String YY = "yy";
	public static final String YYYYMM = "yyyyMM";
	public static final String YYYYMMDD = "yyyyMMdd";
	public static final String YYYYMMDDHH = "yyyyMMddHH";
	public static final String YYYY_MM_DD = "yyyy-MM-dd";
	public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
	public static final String YYYY_MM_DD_HH = "yyyy-MM-dd HH";
	public static final String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
	public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
	public static final String YYYY_M_D_HH_MM_SS = "yyyy/M/d HH:mm:ss";
	public static final String YYYYMMddHHmmssSSS  = "yyyyMMddHHmmssSSS";
	public static final String YYYY_MM ="yyyy-MM";
	/**
	 * 时间格式转中文格式
	 */
	public static String dateToChinese(Date date) {
		SimpleDateFormat formatter =   new SimpleDateFormat( "yyyy年MM月dd日 EEEEaaaa hh:mm", Locale.CHINA);
		return formatter.format(date);
	}
	/**
	 * 字符串转时间格式
	 * 获取现在时间
	 *
	 * @return 返回时间类型 yyyy-MM-dd HH:mm:ss
	 */
	public static Date strToDate(String strDate) {
		if (StringUtils.isEmpty(strDate)) {
			return null;
		}
		else{
			int length = strDate.length();
			if(strDate.contains("/"))
			{
				strDate = strDate.replace("/","-");
			}
			if(strDate.contains("-"))
			{
				if(length == 10)
				{
					 return strToDate(strDate,YYYY_MM_DD);
				}
				else if(length == 19)
				{
					return strToDate(strDate,YYYY_MM_DD_HH_MM_SS);
				}
			}
			else{
				if(length == 8)
				{
					return strToDate(strDate,YYYYMMDD);
				}
				else if(length == 14)
				{
					return strToDate(strDate,YYYYMMDDHHMMSS);
				}
			}
		}
		return null;
	}
	/**
	  * 获取现在时间
	  * 
	  * @return 返回时间类型 yyyy-MM-dd HH:mm:ss
	  */
	public static Date getNowDate() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
@ -93,7 +40,7 @@ DateUtil {
	/**
	 * 获取现在时间
	 * 
	 *
	 * @return返回短时间格式 yyyy-MM-dd
	 */
	public static Date getNowDateShort() {
@ -105,7 +52,7 @@ DateUtil {
	/**
	 * 获取现在时间
	 * 
	 *
	 * @return返回字符串格式 yyyy-MM-dd HH:mm:ss
	 */
	public static String getStringDate() {
@ -114,14 +61,9 @@ DateUtil {
		return formatter.format(currentTime);
	}
	public static String getYyyyMmDdHhMmSs(Date date){
		SimpleDateFormat formatter = new SimpleDateFormat(YYYYMMDDHHMMSS);
		return formatter.format(date);
	}
	/**
	 * 获取现在时间
	 * 
	 *
	 * @return返回字符串格式 yyyy-MM-dd HH:mm:ss
	 */
	public static String getStringDate(String format) {
@ -132,7 +74,7 @@ DateUtil {
	/**
	 * 获取现在时间
	 * 
	 *
	 * @return 返回短时间字符串格式yyyy-MM-dd
	 */
	public static String getStringDateShort() {
@ -143,7 +85,7 @@ DateUtil {
	/**
	 * 获取时间 小时:分;秒 HH:mm:ss
	 * 
	 *
	 * @return
	 */
	public static String getTimeShort() {
@ -154,7 +96,7 @@ DateUtil {
	/**
	 * 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss
	 * 
	 *
	 * @param strDate
	 * @return
	 */
@ -178,31 +120,25 @@ DateUtil {
	/**
	 * 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
	 * 
	 *
	 * @param dateDate
	 * @return
	 */
	public static String dateToStrLong(Date dateDate) {
	public static String dateToStrLong(java.util.Date dateDate) {
		if (dateDate == null) {
			return "";
		}
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
		return formatter.format(dateDate);
	}
	public static String dateToStrNoSecond(Date dateDate) {
		if (dateDate == null) {
			return "";
		}
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM);
		return formatter.format(dateDate);
	}
	/**
	 * 将长时间格式时间转换为字符串 yyyy-MM-dd
	 *
	 * @param dateDate
	 * @return
	 */
	public static String dateToStrShort(Date dateDate) {
	public static String dateToStrShort(java.util.Date dateDate) {
		if (dateDate == null) {
			return "";
		}
@ -212,8 +148,12 @@ DateUtil {
	/**
	 * 将短时间格式时间转换为字符串 yyyy-MM-dd
	 *
	 * @param dateDate
	 * @param
	 * @return
	 */
	public static String dateToStr(Date dateDate, String format) {
	public static String dateToStr(java.util.Date dateDate, String format) {
		if (dateDate == null) {
			return "";
		}
@ -236,8 +176,6 @@ DateUtil {
		return formatter.parse(strDate, pos);
	}
	public static Date strToDateAppendNowTime(String strDate, String format) {
		if (StringUtils.isEmpty(strDate)) {
			return null;
@ -350,8 +288,8 @@ DateUtil {
		SimpleDateFormat myFormatter = new SimpleDateFormat(YYYY_MM_DD);
		long day = 0;
		try {
			Date date = myFormatter.parse(sj1);
			Date mydate = myFormatter.parse(sj2);
			java.util.Date date = myFormatter.parse(sj1);
			java.util.Date mydate = myFormatter.parse(sj2);
			day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
		} catch (Exception e) {
			return "";
@ -359,15 +297,6 @@ DateUtil {
		return day + "";
	}
//	public static void main(String[] args) throws Exception {
//		String a = getTwoDay("2019-12-27","2019-12-28");
//		System.out.println("===>"+a);
//		Integer b = Integer.parseInt(a);
//		System.out.println("===>"+b);
//	}
	/**
	 * 时间前推或后推分钟,其中JJ表示分钟.
	 */
@ -384,23 +313,6 @@ DateUtil {
		return mydate1;
	}
	/**
	 * 时间前推或后推天数(负数前推正数后推)
	 * date 基准时间
	 */
	public static Date getPreDays(Date date, int days) {
		Date day = null;
		try {
			Calendar c = Calendar.getInstance();
			c.setTime(date);
			c.add(Calendar.DATE, days);
			day = c.getTime();
		} catch (Exception e) {
		}
		return day;
	}
	/**
	 * 得到一个时间延后或前移几分钟的时间,nowdate为时间,delay为前移或后延的分钟数
	 */
@ -415,33 +327,6 @@ DateUtil {
		}
	}
	/**
	 * 得到一个时间延后或前移几分钟的时间,d为时间,delay为前移或后延的分钟数
	 */
	public static String getNextMinString(Date d, int days) {
		Calendar c = Calendar.getInstance();
		c.setTime(d);
		c.add(Calendar.MINUTE, days);
		return dateToStr(c.getTime(), "HH:mm");
	}
	/**
	 * 得到一个时间延后或前移几天的时间,nowdate为时间,delay为前移或后延的天数
	 */
	public static String getNextMin(String nowdate, int delay) {
		try {
			SimpleDateFormat format = new SimpleDateFormat(HH_MM);
			String mdate = "";
			Date d = strToDate(nowdate, HH_MM);
			long myTime = (d.getTime() / 1000) + delay * 60;
			d.setTime(myTime * 1000);
			mdate = format.format(d);
			return mdate;
		} catch (Exception e) {
			return "";
		}
	}
	/**
	 * 得到一个时间延后或前移几天的时间,nowdate为时间,delay为前移或后延的天数
	 */
@ -486,13 +371,6 @@ DateUtil {
		return dateToStrShort(c.getTime());
	}
	public static Date getNextMonthReturnDate(Date d, int months) {
		Calendar c = Calendar.getInstance();
		c.setTime(d);
		c.add(Calendar.MONTH, months);
		return c.getTime();
	}
	public static String getNextYear(Date d, int year) {
		Calendar c = Calendar.getInstance();
		c.setTime(d);
@ -500,16 +378,6 @@ DateUtil {
		return dateToStrShort(c.getTime());
	}
	/**
	 * 获取本月第一天
	 * @return
     */
	public static String getCurMonthFirstDayShort(){
		Calendar c = Calendar.getInstance();
		c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
		return dateToStrShort(c.getTime());
	}
	/**
	 * 判断是否润年
	 *
@ -697,8 +565,8 @@ DateUtil {
			return 0;
		// 转换为标准时间
		SimpleDateFormat myFormatter = new SimpleDateFormat(YYYY_MM_DD);
		Date date = null;
		Date mydate = null;
		java.util.Date date = null;
		java.util.Date mydate = null;
		try {
			date = myFormatter.parse(date1);
			mydate = myFormatter.parse(date2);
@ -721,21 +589,6 @@ DateUtil {
		return day;
	}
	/**
	 * 返回两个日期相差的小时数(保留2位小数)
	 * @param date1
	 * @param date2
	 * @return
	 */
	public static float getHours(Date date1, Date date2) {
		if (date1 == null || date2 == null)
			return 0;
		float hours = (date1.getTime() - date2.getTime()) / (float)(60 * 60 * 1000);
		BigDecimal decimal = new BigDecimal(hours);
		float hour = decimal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
		return hour;
	}
	/**
	 * 形成如下的日历 , 根据传入的一个时间返回一个结构 星期日 星期一 星期二 星期三 星期四 星期五 星期六 下面是当月的各个时间
	 * 此函数返回该日历第一行星期日所在的日期
@ -764,15 +617,6 @@ DateUtil {
		return getUserDate("yyyyMMddhhmmss") + getRandom(k);
	}
	/**
	 * 取得流水号 生成格式为yyyymmddhhmmss+k位随机UUID
	 *
	 * @param k 表示是取几位随机数,可以自己定
	 */
	public static String getUidNo(int k) {
		return getUserDate("yyyyMMddhhmmss") + UUID.randomUUID().toString().replaceAll("-", "").substring(0, k);
	}
	/**
	 * 返回一个随机数
	 *
@ -795,92 +639,63 @@ DateUtil {
	 */
	public static int getAgeByBirthday(Date birthday) {
		try {
			int age = 0;
			if (birthday == null) {
				return age;
			}
			String birth = new SimpleDateFormat("yyyyMMdd").format(birthday);
			int year = Integer.valueOf(birth.substring(0, 4));
			int month = Integer.valueOf(birth.substring(4, 6));
			int day = Integer.valueOf(birth.substring(6));
			Calendar cal = Calendar.getInstance();
			age = cal.get(Calendar.YEAR) - year;
			//周岁计算
			if (cal.get(Calendar.MONTH) < (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) < day)) {
				age--;
			if (cal.before(birthday)) {
				return 0;
			}
			int yearNow = cal.get(Calendar.YEAR);
			int monthNow = cal.get(Calendar.MONTH) + 1;
			int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
			cal.setTime(birthday);
			int yearBirth = cal.get(Calendar.YEAR);
			int monthBirth = cal.get(Calendar.MONTH) + 1;
			int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
			int age = yearNow - yearBirth;
			if (monthNow <= monthBirth) {
				if (monthNow == monthBirth) {
					if (dayOfMonthNow < dayOfMonthBirth) {
						age--;
					}
				} else {
					age--;
				}
			}
			return age;
		} catch (Exception e) {
			return 0;
		}
	}
	public static String getNewAge(String birthday) {
		try {
			SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
			Date date =sdf.parse(birthday);
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			Calendar now = Calendar.getInstance();
			int day = now.get(Calendar.DAY_OF_MONTH) - calendar.get(Calendar.DAY_OF_MONTH);
			int month = now.get(Calendar.MONTH) - calendar.get(Calendar.MONTH);
			int year = now.get(Calendar.YEAR) - calendar.get(Calendar.YEAR);
			//按照减法原理,先day相减,不够向month借;然后month相减,不够向year借;最后year相减。
			if(day<0){
				month -= 1;
				now.add(Calendar.MONTH, -1);//得到上一个月,用来得到上个月的天数。
				day = day + now.getActualMaximum(Calendar.DAY_OF_MONTH);
			}
			if(month<0){
				month = (month+12)%12;
				year--;
			}
			if (year==0&&month!=0&&day!=0){
				return month+"月"+day+"天";
			}else if (year!=0&&month!=0&&day!=0){
				return year+"岁"+month+"月"+day+"天";
			}else if (year!=0&&month==0&&day!=0){
				return year+"岁"+day+"天";
			}else if (year!=0&&month!=0&&day==0){
				return year+"岁"+month+"月";
			}else if (year==0&&month==0&&day!=0){
				return day+"天";
			}else if (year!=0&&month==0&&day==0){
				return year+"岁";
			}else if (year==0&&month!=0&&day==0){
				return month+"月";
			}else if (year==0&&month==0&&day==0){
				return "1天";
			}
		} catch (Exception e) {
			return null;
		}
		return null;
	/**
	 * 返回 某年某月某日
	 * @param date
	 * @return
	 */
	public static String getYMD(Date date){
		Instant instant = date.toInstant();
		ZoneId zone = ZoneId.systemDefault();
		LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone);
		LocalDate localDate = localDateTime.toLocalDate();
		return localDate.getYear()+"年"+localDate.getMonth().getValue()+"月"+localDate.getDayOfMonth()+"日";
	}
	public static String  getTimeDifference(Date date1,Date date2){
		long l = date2.getTime() - date1.getTime();
		long day = l / (24 * 60 * 60 * 1000);
		long hour = (l / (60 * 60 * 1000) - day * 24);
		long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60);
		long s = (l / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
		return hour + ":" + min +":" + s;
	}
	/**
	 *  字符串转时间
	 * @param str 时间字符串
	 * @param eg 格式
	 * @return
	 * 时间格式转中文格式
	 */
	public static Date stringToDate(String str, String eg) {
		DateFormat format = new SimpleDateFormat(eg);
		Date date = null;
		if (str != null && !"".equals(str)) {
			try {
				date = format.parse(str);
			} catch (Exception e) {
				return null;
			}
		}
		return date;
	public static String dateToChinese(Date date) {
		SimpleDateFormat formatter =   new SimpleDateFormat( "yyyy年MM月dd日 EEEEaaaa hh:mm", Locale.CHINA);
		return formatter.format(date);
	}
	public static int getNowMonth(){
@ -893,642 +708,11 @@ DateUtil {
		return cal.get(Calendar.YEAR);
	}
	/**
	 * 获取周一
	 * @return
     */
	public static String getMondayOfThisWeek() {
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
		if (day_of_week == 0)
			day_of_week = 7;
		c.add(Calendar.DATE, -day_of_week + 1);
		return df2.format(c.getTime());
	}
	/**
	 * 得到本周周日
	 *
	 * @return yyyy-MM-dd
	 */
	public static String getSundayOfThisWeek() {
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
		if (day_of_week == 0)
			day_of_week = 7;
		c.add(Calendar.DATE, -day_of_week + 7);
		return df2.format(c.getTime());
	}
	/**
	 * 获取当月第一天
	 * @return
     */
	public static String getFristDayOfMonth() {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		// 获取前月的第一天
		Calendar c = Calendar.getInstance();
		c.add(Calendar.MONTH, 0);
		c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
		String first = format.format(c.getTime());
		return format.format(c.getTime());
	}
	/**
	 * 获取当月最后一天
	 */
	public static String getLastDayOfMonth(){
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		// 获取前月的第一天
		Calendar ca = Calendar.getInstance();
		ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
		return format.format(ca.getTime());
	}
	public static int getSignYear(){
		Calendar ca = Calendar.getInstance();
		if(getNowMonth()>=7){
		if(getNowMonth() >= 7){
			return getNowYear();
		}
		return getNowYear()-1;
	}
	/**
	 * 计算预产期
	 * 末次月经开始日期(第一天),月份+9,日期+7
	 * @param date
	 * @return
	 */
	public static Date getDueDate(Date date){
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.MONTH,9);
		cal.add(Calendar.DAY_OF_YEAR,7);
		return cal.getTime();
	}
	/**
	 * 计算产检时间
	 * @param date
	 * @param day
	 * @return
	 */
	public static Date getPrenatalInspectorDate(Date date,Integer day){
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.DAY_OF_YEAR,day);
		return cal.getTime();
	}
	/**
	 * 将HH:MM格式的字符串转TIME
	 * @param hhmm
	 * @return
	 */
	public static Time hhmmStrToTime(String hhmm){
		Time time = null;
		DateFormat sdf = new SimpleDateFormat("HH:mm");
		try {
			Date date = sdf.parse(hhmm);
			time = new Time(date.getTime());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return time;
	}
	/**
	 * 获取当前时间的Timestamp
	 * @return
	 */
	public static Timestamp getNowTimestamp(){
		Date date = new Date();
		Timestamp nousedate = new Timestamp(date.getTime());
		return nousedate;
	}
	/**
	 *  日期加减天数
	 * @param date 时间
	 * @param days 天数�?
	 * @return
	 */
	public static Date setDateTime(Date date, int days){
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.set(Calendar.DATE, cal.get(Calendar.DATE) +(days));
		return  cal.getTime();
	}
	/**
	 *  日期减天数
	 * @param date 时间
	 * @param days 天数�?
	 * @return
	 */
	public static Date setDateTime1(Date date, int days){
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.set(Calendar.DATE, cal.get(Calendar.DATE) -(days));
		return  cal.getTime();
	}
	public static List<Map<String,Object>> findDates(Date dBegin, Date dEnd) {
		List<Map<String,Object>> lDate = new ArrayList();
		Map<String,Object> st = new HashedMap();
		st.put("date",DateUtil.dateToStr(dBegin,"yyyy-MM-dd"));
		st.put("avg",0);
		st.put("count", 0);
		lDate.add(st);
		Calendar calBegin = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calBegin.setTime(dBegin);
		Calendar calEnd = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calEnd.setTime(dEnd);
		// 测试此日期是否在指定日期之后
		while (dEnd.after(calBegin.getTime())) {
			// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
			calBegin.add(Calendar.DAY_OF_MONTH, 1);
			if(!dEnd.after(calBegin.getTime())){
				break;
			}
			Map<String,Object> stt = new HashedMap();
			stt.put("date",DateUtil.dateToStr(calBegin.getTime(),"yyyy-MM-dd"));
			stt.put("avg",0);
			stt.put("count", 0);
			lDate.add(stt);
		}
		return lDate;
	}
	public static List<Map<String,Object>> findWeekASMonth(String startDate,String endDate){
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		// 起始日期
		Calendar start = Calendar.getInstance();
		start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
		// 第一个统计周期结束日期
		String firstEnd = "";
		// 结束日期
		Calendar end = Calendar.getInstance();
		//因为统计时间是统计到当前时间的前一天,所以这里的时间是提前一天
		Calendar temp = Calendar.getInstance();
		temp.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
		end.setTime(temp.getTime());
		// 起始日期为周几
		int week = start.get(Calendar.DAY_OF_WEEK);
		int incre = 7 - week + 1;
		// 日期集合
		List<Calendar> days = new ArrayList<>();
		days.add(start);
		boolean flag = true;
		int i = 0;
		if (startDate.compareTo(endDate) == 0) {
			flag = false;
			days.add(end);
		}
		// 计算统计日期
		while (flag) {
			Calendar next = Calendar.getInstance();
			next.setTime(days.get(days.size() - 1).getTime());
			if (i == 0) {
				if (incre != 7) {
					next.add(Calendar.DATE, incre);
				}
			} else {
				next.add(Calendar.DATE, 7);
			}
			if (next.getTime().before(DateUtil.strToDate(endDate, "yyyy-MM-dd"))) {
				days.add(next);
			} else {
				days.add(end);
				flag = false;
			}
			i++;
		}
		// 结果集
		List<Map<String,Object>> lWeek = new ArrayList<>();
		// 算出每个查询周期
		for (int j = 0; j < days.size() - 1; j++) {
			String endStr = df.format(days.get(j + 1).getTime());
			// 起始、截止日期
			if (j == 0) {
			} else {
				Calendar cal = Calendar.getInstance();
				cal.setTime(days.get(j).getTime());
				cal.add(Calendar.DATE, 1);
			}
			Map<String,Object> range = new HashedMap();
			range.put("date", endStr);
			range.put("avg",0);
			range.put("count",0);
//            countResult.put(endStr, range);
			lWeek.add(range);
		}
		return lWeek;
	}
	public static List<Map<String,Object>> findDateASWeeks(Date dBegin, Date dEnd) {
		List<Map<String,Object>> lDate = new ArrayList();
		Calendar calBegin = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calBegin.setTime(dBegin);
		if(checkDateMonday(calBegin)){
			Map<String,Object> st = new HashedMap();
			st.put("date",DateUtil.dateToStr(dBegin,"yyyy-MM-dd"));
			st.put("avg",0);
			st.put("count",0);
			lDate.add(st);
		}
		Calendar calEnd = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calEnd.setTime(dEnd);
		// 测试此日期是否在指定日期之后
		while (dEnd.after(calBegin.getTime())) {
			// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
			calBegin.add(Calendar.DAY_OF_MONTH, 1);
			/*if(!dEnd.after(calBegin.getTime())){
				break;
			}*/
			if (dEnd.compareTo(calBegin.getTime())==-1){
				break;
			}
			if(checkDateMonday(calBegin)){
				Map<String,Object> stt = new HashedMap();
				stt.put("date",DateUtil.dateToStr(calBegin.getTime(),"yyyy-MM-dd"));
				stt.put("avg",0);
				stt.put("count",0);
				lDate.add(stt);
			}
		}
		return lDate;
	}
	public static List<Map<String,Object>> findDateASMonth(Date dBegin, Date dEnd) {
		List<Map<String,Object>> lDate = new ArrayList();
		Calendar calBegin = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calBegin.setTime(dBegin);
		if(checkFristDayOfDateMonth(calBegin)){
			Map<String,Object> st = new HashedMap();
			st.put("date",DateUtil.dateToStr(dBegin,"yyyy-MM"));
			st.put("avg",0);
			lDate.add(st);
		}
		Calendar calEnd = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calEnd.setTime(dEnd);
		// 测试此日期是否在指定日期之后
		while (dEnd.after(calBegin.getTime())) {
			// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
			calBegin.add(Calendar.DAY_OF_MONTH, 1);
			if(!dEnd.after(calBegin.getTime())){
				break;
			}
			if(checkFristDayOfDateMonth(calBegin)){
				Map<String,Object> stt = new HashedMap();
				stt.put("date",DateUtil.dateToStr(calBegin.getTime(),"yyyy-MM"));
				stt.put("avg",0);
				lDate.add(stt);
			}
		}
		return lDate;
	}
	public static boolean checkDateMonday(Calendar cal){
		int week=cal.get(Calendar.DAY_OF_WEEK)-1;
		if(week ==1){
			return true;
		}else{
			return false;
		}
	}
	public static boolean checkFristDayOfDateMonth(Calendar cal){
		int today = cal.get(cal.DAY_OF_MONTH);
		if(today ==1){
			return true;
		}else{
			return false;
		}
	}
	public static List<Map<String,Object>> getLast6Month(){
		List<Map<String,Object>> rs = new ArrayList<>();
		Calendar dd = Calendar.getInstance();//定义日期实例
		Date endDate = new Date();
		dd.setTime(endDate);
		for(int i=1;i<7;i++){
			Map<String,Object> mc = new HashedMap();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
			String date = sdf.format(dd.getTime());
			mc.put("month",date);
			mc.put("count",0);
			dd.add(Calendar.MONTH,-1);
			rs.add(mc);
		}
		return rs;
	}
	/**
	 * 获取去年日期
	 * @return
     */
	public static String getLastYear(){
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.YEAR,-1);
		return dateToStrLong(cal.getTime());
	}
	/**
	 * 获取儿童的年龄
	 * @param date
	 * @return
     */
	public static String getChildAge(Date date){
		Calendar now = Calendar.getInstance();
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		int year = now.get(Calendar.YEAR)-cal.get(Calendar.YEAR);
		int month = now.get(Calendar.MONTH)-cal.get(Calendar.MONTH);
		if(month<0){
			year--;
			month+=12;
		}
		int day = now.get(Calendar.DAY_OF_MONTH)-cal.get(Calendar.DAY_OF_MONTH);
		if(day<0){
			month--;
			Calendar temp = Calendar.getInstance();
			temp.setTime(date);
			temp.add(Calendar.MONTH,1);
			temp.set(Calendar.DAY_OF_MONTH,1);
			temp.add(Calendar.DAY_OF_MONTH,-1);
			day = temp.get(Calendar.DAY_OF_MONTH)+now.get(Calendar.DAY_OF_MONTH)-cal.get(Calendar.DAY_OF_MONTH);
		}
		String y = year>0? year+"岁":"";
		String m = month>0? month+"月":"";
		String d = day>0? day+"天":"";
		return y+m+d;
	}
	public static int getWeekOfMonth(String dateString){
		Date date = strToDate(dateString);
		return getWeekOfMonth(date);
	}
	public static int getWeekOfMonth(Date date){
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int weekOfMonth = calendar.get(Calendar.WEEK_OF_MONTH);
		return weekOfMonth;
	}
	//将时间维度查出来的quotaDate转成yyyy-MM
	public static String changeQuotaDate(Date quotaDate){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
		String  date = sdf.format(quotaDate);
		return date;
	}
	public static String getYear(String strDate, String format){
		Date date = strToDate(strDate,format);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		return calendar.get(Calendar.YEAR)+"";
	}
	public static String getMonth(String dateString){
		Date date = strToDate(dateString);
		return new SimpleDateFormat(YYYY_MM).format(date);
	}
	/**
	 * 获取周一
	 * @return
	 */
	public static String getMondayOfThisDate(Date date) {
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
		if (day_of_week == 0)
			day_of_week = 7;
		c.add(Calendar.DATE, -day_of_week + 1);
		return df2.format(c.getTime());
	}
	//获取上周一的日期
	public static String getLastWeekMonday(Date date) {
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
		Date a = DateUtils.addDays(date, -1);
		Calendar cal = Calendar.getInstance();
		cal.setTime(a);
		cal.add(Calendar.WEEK_OF_YEAR, -1);// 一周
		cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
		return df2.format(cal.getTime());
	}
	//获取上周日的日期
	public static String  getLastWeekSunday(Date date) {
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
		Date a = DateUtils.addDays(date, -1);
		Calendar cal = Calendar.getInstance();
		cal.setTime(a);
		cal.set(Calendar.DAY_OF_WEEK, 1);
		return df2.format(cal.getTime());
	}
	public static String getMondayOfThisDate(Date date,String format) {
		SimpleDateFormat df2 = new SimpleDateFormat(format);
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
		if (day_of_week == 0)
			day_of_week = 7;
		c.add(Calendar.DATE, -day_of_week + 1);
		return df2.format(c.getTime());
	}
	/**
	 * 得到本周周日
	 *
	 * @return yyyy-MM-dd
	 */
	public static String getSundayOfThisDate(Date date) {
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
		if (day_of_week == 0)
			day_of_week = 7;
		c.add(Calendar.DATE, -day_of_week + 7);
		return df2.format(c.getTime());
	}
	/**
	 * 获取某个时间
	 *
	 * @return返回短时间格式 yyyy-MM-dd
	 */
	public static Date getDateShort(Date date) {
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD);
		String dateString = formatter.format(date);
		return strToDate(dateString, YYYY_MM_DD);
	}
	/**
	 * 获取当月第一天
	 * @return
	 */
	public static String getFristDayOfMonthThisDate(Date date) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		// 获取前月的第一天
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.MONTH, 0);
		c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
		String first = format.format(c.getTime());
		return format.format(c.getTime());
	}
	/**
	 * 获取当月最后一天
	 */
	public static String getLastDayOfMonthThisDate(Date date){
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		// 获取前月的第一天
		Calendar ca = Calendar.getInstance();
		ca.setTime(date);
		ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
		return format.format(ca.getTime());
	}
	
	/**
	 * 根据日期对象返回星期几
	 * @param date
	 * @return
	 */
	public static int getWeekByDate(Date date){
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int week = c.get(Calendar.DAY_OF_WEEK);
		return week;
	}
	//获取本年的开始时间
    public static Date getBeginDayOfYear() {
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.YEAR, getNowYear());
		// cal.set
		cal.set(Calendar.MONTH, Calendar.JANUARY);
		cal.set(Calendar.DATE, 1);
		return getDayStartTime(cal.getTime());
	 }
	//获取本年的结束时间
	public static Date getEndDayOfYear() {
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.YEAR, getNowYear());
		cal.set(Calendar.MONTH, Calendar.DECEMBER);
		cal.set(Calendar.DATE, 31);
		return getDayEndTime(cal.getTime());
	 }
	//获取某个日期的开始时间
	public static Timestamp getDayStartTime(Date d) {
		Calendar calendar = Calendar.getInstance();
		if(null != d) calendar.setTime(d);
		calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
		calendar.set(Calendar.MILLISECOND, 0);
		return new Timestamp(calendar.getTimeInMillis());
	}
	//获取某个日期的结束时间
     public static Timestamp getDayEndTime(Date d) {
		 Calendar calendar = Calendar.getInstance();
		 if(null != d) calendar.setTime(d);
		 calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),    calendar.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
		 calendar.set(Calendar.MILLISECOND, 999);
		 return new Timestamp(calendar.getTimeInMillis());
	 }
	/**
	 * 比较2个时间相差月份
	 * @return
     */
	public static int compareYear(Date start,Date end){
		int re = 1;
		Calendar cal1 = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		cal1.setTime(start);
		cal2.setTime(end);
		int year = cal2.get(Calendar.YEAR)-cal1.get(Calendar.YEAR);
		int month = cal2.get(Calendar.MONTH)-cal1.get(Calendar.MONTH);
		int day = cal2.get(Calendar.DAY_OF_MONTH)-cal1.get(Calendar.DAY_OF_MONTH);
		if(year>0){
			re = year;
			if(month>0){
				re++;
			}else if(month==0&&day>=0){
				re++;
			}
		}
		return re;
	}
	//获取当天的开始时间
	public static String getDayBegin() {
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar cal = new GregorianCalendar();
		cal.set(Calendar.HOUR_OF_DAY, 0);
		cal.set(Calendar.MINUTE, 0);
		cal.set(Calendar.SECOND, 0);
		cal.set(Calendar.MILLISECOND, 0);
		return sdf.format(cal.getTime());
	}
	//获取当天的结束时间
	public static String getDayEnd() {
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar cal = new GregorianCalendar();
		cal.set(Calendar.HOUR_OF_DAY, 23);
		cal.set(Calendar.MINUTE, 59);
		cal.set(Calendar.SECOND, 59);
		return sdf.format(cal.getTime());
	}
	/*public String*/
	public static String getLastDay(String date){
		if (date.contains("06-30")){
			date = date.replace("30","29");
		}
		return date;
	}
}