* fix format2Duration when parameter has one is null
@ -259,6 +259,9 @@ public class DateUtils {
* @return format time
*/
public static String format2Duration(Date d1, Date d2) {
if (d1 == null || d2 == null) {
return null;
}
return format2Duration(differMs(d1, d2));
@ -153,7 +153,7 @@ public class DateUtilsTest {
@Test
public void getCurrentTimeStamp() {
String timeStamp = DateUtils.getCurrentTimeStamp();
Assert.assertNotNull(timeStamp);
@ -196,4 +196,12 @@ public class DateUtilsTest {
public void testNullDuration() {
// days hours minutes seconds
Date d1 = DateUtils.stringToDate("2020-01-20 11:00:00");
Date d2 = null;
Assert.assertNull(DateUtils.format2Duration(d1, d2));