コード例 #1
0
  public void testGetEndOfDay_Date_AlreadyAtEnd() throws Exception {
    logger_.info("Running testGetEndOfDay_Date_AlreadyAtEnd...");

    Date now = new Date();
    Date end = DateTimeUtil.getEndOfDay(now);
    Date endAgain = DateTimeUtil.getEndOfDay(end);
    assertEquals(end, endAgain);
  }
コード例 #2
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);
  }
コード例 #3
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));
  }
コード例 #4
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));
  }
コード例 #5
0
  public void testGetEndOfDay_Date() {
    logger_.info("Running testGetEndOfDay_Date...");

    Date now = new Date();
    Date end = DateTimeUtil.getEndOfDay(now);
    logger_.debug("End of day: " + end);

    Calendar endCal = Calendar.getInstance();
    endCal.setTime(end);

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

    assertEquals(nowCal.get(Calendar.YEAR), endCal.get(Calendar.YEAR));
    assertEquals(nowCal.get(Calendar.MONTH), endCal.get(Calendar.MONTH));
    assertEquals(nowCal.get(Calendar.DATE), endCal.get(Calendar.DATE));
    assertEquals(23, endCal.get(Calendar.HOUR_OF_DAY));
    assertEquals(59, endCal.get(Calendar.MINUTE));
    assertEquals(59, endCal.get(Calendar.SECOND));
    assertEquals(999, endCal.get(Calendar.MILLISECOND));
  }
コード例 #6
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));
  }
コード例 #7
0
  public void testGetEndOfDay() {
    logger_.info("Running testGetEndOfDay...");

    Date now = new Date();
    Date end = DateTimeUtil.getEndOfDay();
    logger_.debug("End of day: " + end);

    Calendar endCal = Calendar.getInstance();
    endCal.setTime(end);

    // 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), endCal.get(Calendar.YEAR));
    assertEquals(nowCal.get(Calendar.MONTH), endCal.get(Calendar.MONTH));
    assertEquals(nowCal.get(Calendar.DATE), endCal.get(Calendar.DATE));
    assertEquals(23, endCal.get(Calendar.HOUR_OF_DAY));
    assertEquals(59, endCal.get(Calendar.MINUTE));
    assertEquals(59, endCal.get(Calendar.SECOND));
    assertEquals(999, endCal.get(Calendar.MILLISECOND));
  }
コード例 #8
0
  public void testFormatToSecond() {
    logger_.info("Running testFormatToSecond...");

    Date d = new Date();
    logger_.debug("Formatted to seconds: " + DateTimeUtil.formatToSecond(d));
  }
コード例 #9
0
  public void testGetEndOfTime() {
    logger_.info("Running testGetEndOfTime...");

    Date d = DateTimeUtil.getEndOfTime();
    logger_.debug("End of time: " + DateTimeUtil.format(d));
  }
コード例 #10
0
  public void testGetStartOfTime() {
    logger_.info("Running testGetBeginningOfTime...");

    Date d = DateTimeUtil.getStartOfTime();
    logger_.debug("Beginning of time: " + DateTimeUtil.format(d));
  }