package com.example.cinema.blImpl; import com.example.cinema.bl.StatisticsService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.text.ParseException; import java.util.Calendar; import java.util.Date; import static org.junit.Assert.*; /** * @author fjj * @date 2019/4/16 3:05 PM */ @RunWith(SpringRunner.class) @SpringBootTest public class StatisticsServiceImplTest { @Autowired private StatisticsService statisticsService; // @Test // public void getScheduleRateByDate() throws ParseException { // System.out.println(getNumDayBeforeDate(new Date(),-5)); // statisticsService.getScheduleRateByDate(getNumDayBeforeDate(new Date(),-5)); // } /** * 获得num天后的日期 * @param oldDate * @param num * @return * @throws ParseException */ Date getNumDayBeforeDate(Date oldDate, int num) throws ParseException { Calendar calendarTime = Calendar.getInstance(); calendarTime.setTime(oldDate); calendarTime.add(Calendar.DAY_OF_YEAR, num); return calendarTime.getTime(); } }