Java中获取当天的0点时间和明天的0点时间
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Date today = calendar.getTime();
calendar.set(DAY_OF_MONTH,calendar.get(DAY_OF_MONTH) +1);
Date tomorrow =calendar.getTime();
String todayString = format.format(today);
String tomorrowString = format.format(tomorrow);
System.out.println("今天是:" + todayString);
System.out.println("明天是:" + tomorrowString);
输出: