Skip to content
Snippets Groups Projects
Commit 6ad1bda8 authored by Mamadu-lamarana Bah's avatar Mamadu-lamarana Bah :speech_balloon:
Browse files

transformation d'un switch en un if-else pour améliorer la lisibilité

parent d363eccc
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@ package com.google.gson.typeadapters;
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,15 @@ public final class UtcDateTypeAdapter extends TypeAdapter<Date> {
@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() == 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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment