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