Пример #1
0
  public void testGetStartOfDay_Date_AlreadyAtStart() throws Exception {
    logger_.info("Running testGetStartOfDay_Date_AlreadyAtStart...");

    Date now = new Date();
    Date start = DateTimeUtil.getStartOfDay(now);
    Date startAgain = DateTimeUtil.getStartOfDay(start);
    assertEquals(start, startAgain);
  }
Пример #2
0
  public void testAdd() {
    logger_.info("Running testAdd...");

    Date d = DateTimeUtil.getStartOfDay();
    logger_.debug("Before adding: " + DateTimeUtil.format(d));

    DateTimeUtil.add(d, 1, 1, 1, 1, 1, 1);
    logger_.debug("After adding: " + DateTimeUtil.format(d));
  }
Пример #3
0
  public void testGetStartOfDay_Date() throws Exception {
    logger_.info("Running testGetStartOfDay_Date...");

    Date now = new Date();
    Date start = DateTimeUtil.getStartOfDay(now);
    logger_.debug("Start of day: " + start);

    Calendar startCal = Calendar.getInstance();
    startCal.setTime(start);

    Calendar nowCal = Calendar.getInstance();
    nowCal.setTime(now);

    assertEquals(nowCal.get(Calendar.YEAR), startCal.get(Calendar.YEAR));
    assertEquals(nowCal.get(Calendar.MONTH), startCal.get(Calendar.MONTH));
    assertEquals(nowCal.get(Calendar.DATE), startCal.get(Calendar.DATE));
    assertEquals(0, startCal.get(Calendar.HOUR_OF_DAY));
    assertEquals(0, startCal.get(Calendar.MINUTE));
    assertEquals(0, startCal.get(Calendar.SECOND));
    assertEquals(0, startCal.get(Calendar.MILLISECOND));
  }
Пример #4
0
  public void testGetStartOfDay() throws Exception {
    logger_.info("Running testGetStartOfDay...");

    Date now = new Date();
    Date start = DateTimeUtil.getStartOfDay();
    logger_.debug("Start of day: " + start);

    Calendar startCal = Calendar.getInstance();
    startCal.setTime(start);

    // There is the possibility that if the first two lines of this test run
    // on the end of day boundary (23:59:59 999) that this test will fail.
    Calendar nowCal = Calendar.getInstance();
    nowCal.setTime(now);

    assertEquals(nowCal.get(Calendar.YEAR), startCal.get(Calendar.YEAR));
    assertEquals(nowCal.get(Calendar.MONTH), startCal.get(Calendar.MONTH));
    assertEquals(nowCal.get(Calendar.DATE), startCal.get(Calendar.DATE));
    assertEquals(0, startCal.get(Calendar.HOUR_OF_DAY));
    assertEquals(0, startCal.get(Calendar.MINUTE));
    assertEquals(0, startCal.get(Calendar.SECOND));
    assertEquals(0, startCal.get(Calendar.MILLISECOND));
  }