Code example for JsonReader

Methods: nextNullpeek

0
 * */ 
 
public class NetDateTimeAdapter extends TypeAdapter<Date> {
    @Override 
    public Date read(JsonReader reader) throws IOException {
        if (reader.peek() == JsonToken.NULL) {
            reader.nextNull();
            return null; 
        } 
        Date result = null;
        String str = reader.nextString();
        str = str.replaceAll("[^0-9]", "");
        if (!TextUtils.isEmpty(str)) {
            try { 
                result = new Date(Long.parseLong(str));
            } catch (NumberFormatException e) {
            } 
        } 
        return result;
    }