import java.util.Calendar;
import java.util.Date;
class Test {
public static void main(String[] args) {
System.out.println("hello start");
parseDate(new Date(),new Date());
System.out.println("hello end");
}
private static void parseDate(Date date1,Date date2){
Calendar c = Calendar.getInstance();
if(date1!=null){
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
System.out.println(c.getTime());
}
if(date2!=null){
c.set(Calendar.HOUR_OF_DAY, 23);
c.set(Calendar.MINUTE, 59);
c.set(Calendar.SECOND, 59);
c.set(Calendar.MILLISECOND, 999);
System.out.println(c.getTime());
}
}
}
运行结果:
hello start
Mon Oct 10 00:00:00 UTC 2016
Mon Oct 10 23:59:59 UTC 2016
hello end
转载于:https://blog.51cto.com/zhangyh8856643/1860260