Skip to content

JodaDateSerializer Discards Shape Override Preference #108

@knocknarea

Description

@knocknarea

If you create a Serializer (for example LocalTimeSerializer) with a String shape preference, this preference get discarded at this point

if ((format != _format) || (shapeOverride != _shapeOverride)) {

example

class DTO {
   LocalTime timeIn;
}

Configure Module

module.addSerializer(LocalTime.class, new LocalTimeShapedDeserializer(
	    		new JacksonJodaDateFormat(ISODateTimeFormat.hourMinute()), 1));

When the above DTO is serialized, the time is rendered [ hh, mm, sec, ms ] instead of the desired and configured way

The fact that the LocalTime.class serializer has been created to use the string shape (in this instance "hh:mm") gets ignored and in the above code

            } else  {
                useTimestamp = null;
                shapeOverride = 0; // should this not be set to _shapeOverride??
            }
            // must not call if flag defined, to rely on defaults:
            if (useTimestamp != null) {
                format = format.withUseTimestamp(useTimestamp);
            }
            format = format.with(ann);
            if ((format != _format) || (shapeOverride != _shapeOverride)) {
                return withFormat(format, shapeOverride);
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions