Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.datatype.joda.deser;
 
 
 
    public LocalDateTimeDeserializer() { super(LocalDateTime.class); }
    @Override
        throws IOExceptionJsonProcessingException
    {
        // We'll accept either long (timestamp) or array:
        if (jp.isExpectedStartArrayToken()) {
            jp.nextToken(); // VALUE_NUMBER_INT
            int year = jp.getIntValue();
            jp.nextToken(); // VALUE_NUMBER_INT
            int month = jp.getIntValue();
            jp.nextToken(); // VALUE_NUMBER_INT
            int day = jp.getIntValue();
            jp.nextToken(); // VALUE_NUMBER_INT
            int hour = jp.getIntValue();
            jp.nextToken(); // VALUE_NUMBER_INT
            int minute = jp.getIntValue();
            jp.nextToken(); // VALUE_NUMBER_INT
            int second = jp.getIntValue();
            // let's leave milliseconds optional?
            int millisecond = 0;
            if (jp.nextToken() != .) { // VALUE_NUMBER_INT           
                millisecond = jp.getIntValue();
                jp.nextToken(); // END_ARRAY?
            }
            if (jp.getCurrentToken() != .) {
                throw ctxt.wrongTokenException(jp."after LocalDateTime ints");
            }
            return new LocalDateTime(yearmonthdayhourminutesecondmillisecond);                 
        }
        switch (jp.getCurrentToken()) {
        case :
            return new LocalDateTime(jp.getLongValue());            
        case :
            DateTime local = parseLocal(jp);
            if (local == null) {
                return null;
            }
            return local.toLocalDateTime();
        }
        throw ctxt.wrongTokenException(jp."expected JSON Array or Number");
    }
New to GrepCode? Check out our FAQ X