Hi Team,

Please find the below test case and observation which seems to be a bug in
the DurationFormatUtils class. If you look at the calculated duration it
says "Duration : *00-11130235300000*" with output format as
yyyyMMddHHmmssSSS.

<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<scope>provided</scope>

@Test
void getElapsedTimerTest() {

String DATE_TIME_FORMAT = "yyyyMMddHHmmssSSS";
long startEpochMillis = 1698541052000L; //Date and time (GMT): Sunday, 29
October 2023 00:57:32
long endEpochMillis = 1698544232000L; //Date and time (GMT): Sunday, 29
October 2023 01:50:32

String duration = DurationFormatUtils.formatPeriod(startEpochMillis,
endEpochMillis, DATE_TIME_FORMAT);

System.out.println("Start Time : " + Instant.ofEpochMilli(startEpochMillis))
;
System.out.println("End Time : " + Instant.ofEpochMilli(endEpochMillis));
System.out.println("Duration : " + duration);


}

Console Output:

Start Time : 2023-10-29T00:57:32Z End Time : 2023-10-29T01:50:32Z Duration
: *00-11130235300000*

Regards,
Sujan Biswas

Reply via email to