Java Unit Test Library-Artery-Current Date Judgment

Table of Contents ⇒ Java Unit Test Library-Artery-Sample

package jp.avaj.lib.test;

import java.util.Calendar;

import jp.avaj.lib.algo.ArDateUtil;

/**
Java unit test library-Artery-Current date judgment

 ArDate,Date,Calendar,Determine if long is the current date.

This sample shows the case of Calendar.
 */
public class Q05_00 {
  public static void main(String[] args) {
    //Start a test case, unnecessary if you don't need to aggregate the results
    ArTest.startTestCase("Q05_00");

    //Get the current date and time
    Calendar cal = ArDateUtil.getCalendar();
    //Determine if it is the current date
    ArTest.currentDate("Current date and time","cal",cal);

    //Advance two hours ⇒ If it is before 22:00, the current date
    cal = ArDateUtil.forward(cal,0,2,0,0);
    ArTest.currentDate("Current date and time + 2 hours","cal",cal);

    //Advance one day ⇒ Not the current day
    cal = ArDateUtil.forward(cal,1,0,0,0);
    ArTest.currentDate("Current date and time + 1 day + 2 hours ⇒ NG","cal",cal);

    //End the test case, unnecessary if you don't need to aggregate the results
    ArTest.endTestCase();
  }
}

The result is as follows.

result.txt


**** Q05_00 start ****
OK current date and time:cal=2019/09/30 07:39:27
OK Current date and time + 2 hours:cal=2019/09/30 09:39:27
NG Current date and time + 1 day + 2 hours ⇒ NG:cal=2019/10/01 09:39:27
jp.avaj.lib.test.Q05_00.main(Q05_00.java:30)
**** Q05_00 summary ****
test count = 3
success    = 2

Recommended Posts

Java Unit Test Library-Artery-Current Date Judgment
Java Unit Test Library-Artery / JUnit4-Numerical equality judgment
Java Unit Test Library-Artery-Sample
Java Unit Test Library-Artery / JUnit4-Array Equivalence
Java Artery-Easy to use unit test library
Automatic creation of Java unit test result report
Java unit test Same day judgment ArDate, Date, Calendar, long ignore the time and judge whether they are the same day
Java unit test Judgment of specified day of the week Determines whether ArDate, Date, Calendar, and long are specified days of the week.
[Java] Date / time operations
[Java] Holiday judgment sample
Java basic date manipulation
Date manipulation in Java 8
Unit test with Junit.
java: Add date [Note]
[Java] Date type conversion
[Java] JUnit4 test case example
[IntelliJ IDEA] Perform Unit Test
Introduction to Micronaut 2 ~ Unit test ~
Fastest Primality Test C # Java C ++
Java test code method collection
2018 Java Proficiency Test for Newcomers-Basics-
Unit test architecture using ArchUnit
[Java] Date Related Term Memo
Implementation of unit test code
[Java] Multiple OR condition judgment
View current date in Java
Java unit tests with Mockito