1
1
package cloud .eppo ;
2
2
3
- import com .google . gson . JsonElement ;
3
+ import com .fasterxml . jackson . databind . JsonNode ;
4
4
import java .math .BigInteger ;
5
5
import java .security .MessageDigest ;
6
6
import java .security .NoSuchAlgorithmException ;
13
13
import org .slf4j .LoggerFactory ;
14
14
15
15
public final class Utils {
16
- private static final SimpleDateFormat isoUtcDateFormat = buildUtcIsoDateFormat ();
16
+ private static final SimpleDateFormat UTC_ISO_DATE_FORMAT = buildUtcIsoDateFormat ();
17
17
private static final Logger log = LoggerFactory .getLogger (Utils .class );
18
18
19
19
public static String getMD5Hex (String input ) {
@@ -33,14 +33,14 @@ public static String getMD5Hex(String input) {
33
33
return hashText .toString ();
34
34
}
35
35
36
- public static Date parseUtcISODateElement (JsonElement isoDateStringElement ) {
37
- if (isoDateStringElement == null || isoDateStringElement .isJsonNull ()) {
36
+ public static Date parseUtcISODateElement (JsonNode isoDateStringElement ) {
37
+ if (isoDateStringElement == null || isoDateStringElement .isNull ()) {
38
38
return null ;
39
39
}
40
- String isoDateString = isoDateStringElement .getAsString ();
40
+ String isoDateString = isoDateStringElement .asText ();
41
41
Date result = null ;
42
42
try {
43
- result = isoUtcDateFormat .parse (isoDateString );
43
+ result = UTC_ISO_DATE_FORMAT .parse (isoDateString );
44
44
} catch (ParseException e ) {
45
45
// We expect to fail parsing if the date is base 64 encoded
46
46
// Thus we'll leave the result null for now and try again with the decoded value
@@ -50,7 +50,7 @@ public static Date parseUtcISODateElement(JsonElement isoDateStringElement) {
50
50
// Date may be encoded
51
51
String decodedIsoDateString = base64Decode (isoDateString );
52
52
try {
53
- result = isoUtcDateFormat .parse (decodedIsoDateString );
53
+ result = UTC_ISO_DATE_FORMAT .parse (decodedIsoDateString );
54
54
} catch (ParseException e ) {
55
55
log .warn ("Date \" {}\" not in ISO date format" , isoDateString );
56
56
}
@@ -60,7 +60,7 @@ public static Date parseUtcISODateElement(JsonElement isoDateStringElement) {
60
60
}
61
61
62
62
public static String getISODate (Date date ) {
63
- return isoUtcDateFormat .format (date );
63
+ return UTC_ISO_DATE_FORMAT .format (date );
64
64
}
65
65
66
66
public static String base64Decode (String input ) {
0 commit comments