java判断员工入职时间工具类

public class DateUtils {
	//使工具类方法私有化,只传递一个简化的方法,降低耦合
	private static String getOneWeek(Calendar cdate,Calendar cdateNew){
		cdate.add(Calendar.DATE, 7);
		if(cdate.getTimeInMillis()>cdateNew.getTimeInMillis()){
			System.out.println("小于1周");
			return null;
		}
		else if(cdate.getTimeInMillis()==cdateNew.getTimeInMillis())
			return "一周";
		else if(cdate.getTimeInMillis()cdateNew.getTimeInMillis()){
			System.out.println("小于1月");
			return null;
		}
		else if(cdate.getTimeInMillis()==cdateNew.getTimeInMillis())
			return "一个月";
		else if(cdate.getTimeInMillis()cdateNew.getTimeInMillis()){
			System.out.println("小于三月");
			return null;
		}
		else if(cdate.getTimeInMillis()==cdateNew.getTimeInMillis())
			return "三个月";
		else if(cdate.getTimeInMillis()cdateNew.getTimeInMillis()){
			System.out.println("小于1年");
			return null;
		}
		else if(cdate.getTimeInMillis()==cdateNew.getTimeInMillis())
			return "一年";
		else if(cdate.getTimeInMillis()cdateNew.getTimeInMillis()){
			System.out.println("小于5年");
			return null;
		}
		else if(cdate.getTimeInMillis()==cdateNew.getTimeInMillis())
			return "五年";
		else if(cdate.getTimeInMillis()cdateNew.getTimeInMillis()){
			return null;
		}
		else if(cdate.getTimeInMillis()==cdateNew.getTimeInMillis())
			return "十年";
		else if(cdate.getTimeInMillis()
public class TestDate {

	public static Date dateConver(Date cdate,Date cdateNew){//去除时分秒
		int year=cdate.getYear();
		int month=cdate.getMonth();
		int day=cdate.getDate();
		cdateNew.setYear(year);
		cdateNew.setMonth(month);
		cdateNew.setDate(day);
		return cdateNew;
	}
	public static String getMeessage(Date dateUser) {
		Date date = new Date();
		Calendar c = Calendar.getInstance();
		c.setTime(new Date());

		Calendar cNew = Calendar.getInstance();//当前时间
		cNew.setTime(date);
		Date newDate=cNew.getTime();
		cNew.setTime(newDate);
		
		Date cdate=dateConver(c.getTime(),date);//用户入职时间
		cdate.setYear(dateUser.getYear());
		cdate.setMonth(dateUser.getMonth());
		cdate.setDate(dateUser.getDate());
		c.setTime(cdate);

		return DateUtils.getSimplifyJudge(c, cNew);
	}
}

你可能感兴趣的:(java)