1 | package org.cardanofoundation.explorer.api.util; | |
2 | ||
3 | import java.sql.Timestamp; | |
4 | import java.text.DateFormat; | |
5 | import java.text.SimpleDateFormat; | |
6 | import java.util.Date; | |
7 | import java.util.Objects; | |
8 | ||
9 | import lombok.SneakyThrows; | |
10 | import lombok.extern.log4j.Log4j2; | |
11 | ||
12 | @Log4j2 | |
13 | public final class TimeUtil { | |
14 | ||
15 | public static final String DATE_FORMAT_DEFAULT = "dd/MM/yyyy"; | |
16 | ||
17 | private TimeUtil() {} | |
18 | ||
19 | @SneakyThrows | |
20 | public static Date formatDate(Timestamp timestamp) { | |
21 |
1
1. formatDate : replaced return value with null for org/cardanofoundation/explorer/api/util/TimeUtil::formatDate → NO_COVERAGE |
return formatDate(timestamp, null); |
22 | } | |
23 | ||
24 | @SneakyThrows | |
25 | public static Date formatDate(Timestamp timestamp, String pattern) { | |
26 | DateFormat formatter = | |
27 |
1
1. formatDate : negated conditional → NO_COVERAGE |
new SimpleDateFormat(Objects.isNull(pattern) ? DATE_FORMAT_DEFAULT : pattern); |
28 |
1
1. formatDate : replaced return value with null for org/cardanofoundation/explorer/api/util/TimeUtil::formatDate → NO_COVERAGE |
return formatter.parse(formatter.format(new Date(timestamp.getTime()))); |
29 | } | |
30 | } | |
Mutations | ||
21 |
1.1 |
|
27 |
1.1 |
|
28 |
1.1 |