Table of Contents ⇒ Java Unit Test Library-Artery-Sample
Q05_02.java
package jp.avaj.lib.test;
import java.util.Date;
import jp.avaj.lib.algo.ArDate;
import jp.avaj.lib.algo.ArDateUtil;
/**
Java Unit Test Same Day Judgment ArDate,Date,Calendar,Determine if long is the same day, ignoring the time
・ This sample shows a sample that compares ArDate and Date, but any combination of the above can be compared..
・ Note, ArDate holds only the date and does not handle the time..
*/
public class Q05_02 {
public static void main(String[] args) {
//Start a test case.
ArTest.startTestCase("Q05_02");
//On the day
ArDate arDate0 = new ArDate();
//On the day, at the time
Date date1 = new Date();
//If you compare this, the same day
ArTest.sameDate("ArDate vs Date","arDate0",arDate0,"date1",date1);
//Advance date1 by one hour, argument is day → hour → minute, this method is Calendar,Can also be used with long.
date1 = ArDateUtil.forward(date1,0,1,0,0);
// (If you run this test before 23:00)Same day
ArTest.sameDate("ArDate vs Date","arDate0",arDate0,"date1",date1);
//Advance arDate0 for a day
arDate0.forward(1);
//If you compare both, they are not on the same day
ArTest.notSameDate("ArDate vs Date","arDate0",arDate0,"date1",date1);
//Advance date1 by one day,
date1 = ArDateUtil.forward(date1,1,0,0,0);
//It will be the same day again
ArTest.sameDate("ArDate vs Date","arDate0",arDate0,"date1",date1);
//
//End the test case
ArTest.endTestCase();
}
}
The result is as follows
result.txt
**** Q05_02 start ****
OK ArDate vs Date:arDate0=2019/10/23:date1=2019/10/23 06:37:09
OK ArDate vs Date:arDate0=2019/10/23:date1=2019/10/23 07:37:09
OK ArDate vs Date:arDate0=2019/10/24:date1=2019/10/23 07:37:09
OK ArDate vs Date:arDate0=2019/10/24:date1=2019/10/24 07:37:09
**** Q05_02 summary ****
test count = 4
success = 4
Recommended Posts