Skip to content

Commit 7b60f90

Browse files
committed
prevent potential NPEs [ci skip]
1 parent 7337135 commit 7b60f90

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/main/java/de/rwth/idsg/steve/utils/JodaDateTimeConverter.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import javax.xml.bind.annotation.adapters.XmlAdapter;
66

7+
import static com.google.common.base.Strings.isNullOrEmpty;
8+
79
/**
810
* Joda-Time and XSD represent data and time information according to ISO 8601.
911
*
@@ -14,11 +16,19 @@ public class JodaDateTimeConverter extends XmlAdapter<String, DateTime> {
1416

1517
@Override
1618
public DateTime unmarshal(String v) throws Exception {
17-
return new DateTime(v);
19+
if (isNullOrEmpty(v)) {
20+
return null;
21+
} else {
22+
return new DateTime(v);
23+
}
1824
}
1925

2026
@Override
2127
public String marshal(DateTime v) throws Exception {
22-
return v.toString();
28+
if (v == null) {
29+
return null;
30+
} else {
31+
return v.toString();
32+
}
2333
}
2434
}

0 commit comments

Comments
 (0)