Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.datatype.joda.deser;
 
 
 
Deserializes a Duration from either an int number of millis or using the org.joda.time.Duration.(java.lang.Object) constructor on a JSON string. By default the only supported string format is that used by org.joda.time.base.AbstractDuration.toString(). (That format for a 3,248 millisecond duration is "PT3.248S".)
public final class DurationDeserializer extends StdScalarDeserializer<Duration>
    public DurationDeserializer() { super(Duration.class); }
    @Override
    public Duration deserialize(JsonParser jsonParserDeserializationContext deserializationContextthrows
    {
        switch (jsonParser.getCurrentToken()) {
        case // assume it's millisecond count
            return new Duration(jsonParser.getLongValue());
        case :
            return new Duration(jsonParser.getText());
        }
        throw deserializationContext.mappingException("expected JSON Number or String");
    }
New to GrepCode? Check out our FAQ X