| | |
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | |
|
| | |
|
| | | public class DateUtil {
|
| | |
|
| | | public static String dateDiff(String startTime, String endTime) {
|
| | |
| | | return datatime;
|
| | | }
|
| | |
|
| | | |
| | | public static String dateDiff2(Date startTime, Date endTime) throws Exception{
|
| | |
|
| | | String datatime = 0 + "天" + 0 + "小时" + 0 + "分钟" ;
|
| | |
| | | long hour = diff % nd / nh;// 计算差多少小时
|
| | | long min = diff % nd % nh / nm;// 计算差多少分钟
|
| | |
|
| | | |
| | | datatime = day + "天" + hour + "小时" + min + "分钟" ;
|
| | | |
| | |
|
| | | return datatime;
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 指定日期加上天数后的日期
|
| | | * |
| | | * @param num
|
| | | * 为增加的天数
|
| | | * @param nowDate
|
| | | * 创建时间
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | public static String plusDay(int num, String nowDate) throws ParseException {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
| | | Date currdate = format.parse(nowDate);
|
| | | |
| | | Calendar ca = Calendar.getInstance();
|
| | | ca.setTime(currdate);
|
| | | ca.add(Calendar.DATE, num);
|
| | | |
| | | return format.format(ca.getTime());
|
| | | }
|
| | | } |