StatisticsServiceImplTest.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.example.cinema.blImpl;
  2. import com.example.cinema.bl.StatisticsService;
  3. import org.junit.Test;
  4. import org.junit.runner.RunWith;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.boot.test.context.SpringBootTest;
  7. import org.springframework.test.context.junit4.SpringRunner;
  8. import java.text.ParseException;
  9. import java.util.Calendar;
  10. import java.util.Date;
  11. import static org.junit.Assert.*;
  12. /**
  13. * @author fjj
  14. * @date 2019/4/16 3:05 PM
  15. */
  16. @RunWith(SpringRunner.class)
  17. @SpringBootTest
  18. public class StatisticsServiceImplTest {
  19. @Autowired
  20. private StatisticsService statisticsService;
  21. // @Test
  22. // public void getScheduleRateByDate() throws ParseException {
  23. // System.out.println(getNumDayBeforeDate(new Date(),-5));
  24. // statisticsService.getScheduleRateByDate(getNumDayBeforeDate(new Date(),-5));
  25. // }
  26. /**
  27. * 获得num天后的日期
  28. * @param oldDate
  29. * @param num
  30. * @return
  31. * @throws ParseException
  32. */
  33. Date getNumDayBeforeDate(Date oldDate, int num) throws ParseException {
  34. Calendar calendarTime = Calendar.getInstance();
  35. calendarTime.setTime(oldDate);
  36. calendarTime.add(Calendar.DAY_OF_YEAR, num);
  37. return calendarTime.getTime();
  38. }
  39. }