diff --git a/extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java b/extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java index 4b2356c1b2..be6628d3bf 100644 --- a/extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java +++ b/extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java @@ -19,6 +19,7 @@ import com.google.gson.JsonParseException; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.text.ParseException; @@ -45,15 +46,14 @@ public void write(JsonWriter out, Date date) throws IOException { @Override public Date read(JsonReader in) throws IOException { try { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - // Instead of using iso8601Format.parse(value), we use Jackson's date parsing - // This is because Android doesn't support XXX because it is JDK 1.6 - return parse(date, new ParsePosition(0)); + if (in.peek().equals(JsonToken.NULL)) { + in.nextNull(); + return null; + } else { + String date = in.nextString(); + // Instead of using iso8601Format.parse(value), we use Jackson's date parsing + // This is because Android doesn't support XXX because it is JDK 1.6 + return parse(date, new ParsePosition(0)); } } catch (ParseException e) { throw new JsonParseException(e);