Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.datatype.joda.deser;
 
 
 
    final static DateTimeFormatter parser = ISODateTimeFormat.localDateOptionalTimeParser();
    public LocalDateTimeDeserializer() { super(LocalDateTime.class); }
    @Override
        throws IOExceptionJsonProcessingException
    {
        switch (jp.getCurrentToken()) {
        case :
            // [yyyy,mm,dd,hh,MM,ss,ms]
            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();
                jp.nextToken(); // VALUE_NUMBER_INT | END_ARRAY
                // let's leave milliseconds optional?
                int millisecond = 0;
                if (jp.getCurrentToken() != .) { // VALUE_NUMBER_INT           
                    millisecond = jp.getIntValue();
                    jp.nextToken(); // END_ARRAY?
                }
                if (jp.getCurrentToken() != .) {
                    throw ctxt.wrongTokenException(jp."after LocalDateTime ints");
                }
                return new LocalDateTime(yearmonthdayhourminutesecondmillisecond);                 
            }
            break;
        case :
            return new LocalDateTime(jp.getLongValue());            
        case :
            String str = jp.getText().trim();
            if (str.length() == 0) { // [JACKSON-360]
                return null;
            }
            return .parseLocalDateTime(str);
        }
        throw ctxt.wrongTokenException(jp."expected JSON Array, Number or String");
    }
New to GrepCode? Check out our FAQ X