package com.ibeetl.admin.core.util;
|
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.Calendar;
|
import java.util.Date;
|
|
public class DateUtil {
|
|
public static Date MAX_DATE = maxDate();
|
|
public static int daysBetween(String smdate,String bdate) throws ParseException {
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
Calendar cal = Calendar.getInstance();
|
cal.setTime(sdf.parse(smdate));
|
long time1 = cal.getTimeInMillis();
|
cal.setTime(sdf.parse(bdate));
|
long time2 = cal.getTimeInMillis();
|
long between_days=(time2-time1)/(1000*3600*24);
|
return Integer.parseInt(String.valueOf(between_days));
|
}
|
|
public static String now() {
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
return sdf.format(new Date());
|
}
|
|
public static String now(String format) {
|
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
return sdf.format(new Date());
|
}
|
|
private static Date maxDate() {
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
try {
|
return sdf.parse("9999-12-31 23:59:59");
|
} catch (ParseException e) {
|
throw new RuntimeException(e);
|
}
|
}
|
}
|