java处理日期工具类
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateUtils
{
public static String getDateDir(int threshold)
{
Calendar cd = Calendar.getInstance();
cd.setTime(new Date(System.currentTimeMillis()));
cd.add(Calendar.DATE, threshold);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date currentDate = cd.getTime();
return sdf.format(currentDate);
}
public static String getToday()
{
Calendar cd = Calendar.getInstance();
cd.setTime(new Date(System.currentTimeMillis()));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date currentDate = cd.getTime();
return sdf.format(currentDate);
}
public static Date getDateForJobTime(String d1, String p1) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
p1 = p1 ==null? "23:59" : p1;
return sdf.parse(d1 +" "+ p1);
}
}