Commit 0b427421 authored by Emmanuel Bourg's avatar Emmanuel Bourg

New upstream version 2.9.8

parent ff63e0cc
......@@ -4,12 +4,12 @@
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
<version>2.9.4</version>
<version>2.9.8</version>
</parent>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<name>Jackson-datatype-Joda</name>
<version>2.9.4</version>
<version>2.9.8</version>
<packaging>bundle</packaging>
<description>Add-on module for Jackson (http://jackson.codehaus.org) to support
Joda (http://joda-time.sourceforge.net/) data types.
......@@ -19,7 +19,7 @@ Joda (http://joda-time.sourceforge.net/) data types.
<connection>scm:git:git@github.com:FasterXML/jackson-datatype-joda.git</connection>
<developerConnection>scm:git:git@github.com:FasterXML/jackson-datatype-joda.git</developerConnection>
<url>http://github.com/FasterXML/jackson-datatype-joda</url>
<tag>jackson-datatype-joda-2.9.4</tag>
<tag>jackson-datatype-joda-2.9.8</tag>
</scm>
<properties>
<!-- Generate PackageVersion.java into this directory. -->
......
......@@ -71,3 +71,8 @@ Daniel Qian (chanjarster@github)
* Reported, contributed fix for #93: ADJUST_DATES_TO_CONTEXT_TIME_ZONE got wrong result
when parse string contains zone id
(2.9.0)
Adrian Palanques (devdevx@github)
* Reported, contributed fix for #101: Instant, YearMonth and MonthDay not use
pattern in @JsonFormat
(2.9.7)
......@@ -4,6 +4,19 @@ Project: jackson-datatype-joda
=== Releases ===
------------------------------------------------------------------------
2.9.8 (15-Dec-2018)
No changes since 2.9.7
2.9.7 (19-Sep-2018)
#99: Binary compatibility broken in 2.9.x in `DateTimeSerializer`
(reported, fixed by andrewl102@github)
#101: Instant, YearMonth and MonthDay not use pattern in @JsonFormat
(reported, fixed by Adrian P)
2.9.6 (12-Jun-2018)
2.9.5 (26-Mar-2018)
2.9.4 (24-Jan-2018)
2.9.3 (09-Dec-2017)
2.9.2 (14-Oct-2017)
......
package com.fasterxml.jackson.datatype.joda;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.datatype.joda.deser.*;
import com.fasterxml.jackson.datatype.joda.deser.key.*;
import com.fasterxml.jackson.datatype.joda.ser.*;
......@@ -37,7 +35,6 @@ public class JodaModule extends SimpleModule
addDeserializer(YearMonth.class, new YearMonthDeserializer());
// then serializers:
final JsonSerializer<Object> stringSer = ToStringSerializer.instance;
addSerializer(DateTime.class, new DateTimeSerializer());
addSerializer(DateTimeZone.class, new DateTimeZoneSerializer());
addSerializer(Duration.class, new DurationSerializer());
......@@ -47,8 +44,8 @@ public class JodaModule extends SimpleModule
addSerializer(LocalTime.class, new LocalTimeSerializer());
addSerializer(Period.class, new PeriodSerializer());
addSerializer(Interval.class, new IntervalSerializer());
addSerializer(MonthDay.class, stringSer);
addSerializer(YearMonth.class, stringSer);
addSerializer(MonthDay.class, new MonthDaySerializer());
addSerializer(YearMonth.class, new YearMonthSerializer());
// then key deserializers
addKeyDeserializer(DateTime.class, new DateTimeKeyDeserializer());
......
package com.fasterxml.jackson.datatype.joda.cfg;
import java.util.Arrays;
import org.joda.time.DateTimeZone;
import org.joda.time.DateTimeFieldType;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import org.joda.time.format.ISOPeriodFormat;
......@@ -62,19 +65,28 @@ public class FormatConfig
public final static JacksonJodaPeriodFormat DEFAULT_PERIOD_FORMAT
= new JacksonJodaPeriodFormat(ISOPeriodFormat.standard());
public final static JacksonJodaDateFormat DEFAULT_YEAR_MONTH_FORMAT
= new JacksonJodaDateFormat(ISODateTimeFormat.yearMonth());
public final static JacksonJodaDateFormat DEFAULT_MONTH_DAY_FORMAT
= createMonthDayFormat();
// // // And then some wrapper methods for improved diagnostics, and possible
// // // default settings for things like "withOffsetParsed()" (see
// // // [dataformat-joda#75] for more information)
private final static JacksonJodaDateFormat createUTC(DateTimeFormatter f)
{
f = f.withZoneUTC();
return new JacksonJodaDateFormat(f);
private final static JacksonJodaDateFormat createUTC(DateTimeFormatter f) {
return new JacksonJodaDateFormat(f.withZoneUTC());
}
private final static JacksonJodaDateFormat createDefaultTZ(DateTimeFormatter f) {
return new JacksonJodaDateFormat(f.withZone(DEFAULT_TZ));
}
private final static JacksonJodaDateFormat createDefaultTZ(DateTimeFormatter f)
private final static JacksonJodaDateFormat createMonthDayFormat()
{
f = f.withZone(DEFAULT_TZ);
return new JacksonJodaDateFormat(f);
return new JacksonJodaDateFormat(ISODateTimeFormat.forFields(
Arrays.asList(DateTimeFieldType.monthOfYear(), DateTimeFieldType.dayOfMonth()),
true, true));
}
}
......@@ -4,17 +4,11 @@ import java.io.IOException;
import org.joda.time.Duration;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonTokenId;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
import com.fasterxml.jackson.datatype.joda.cfg.FormatConfig;
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat;
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaPeriodFormat;
/**
......
......@@ -7,6 +7,8 @@ import org.joda.time.Instant;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.datatype.joda.cfg.FormatConfig;
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat;
/**
* Basic deserializer for {@link org.joda.time.ReadableDateTime} and its subtypes.
......@@ -14,12 +16,21 @@ import com.fasterxml.jackson.databind.*;
* Does not (yet?) support JSON object; support can be added if desired.
*/
public class InstantDeserializer
extends JodaDeserializerBase<Instant>
extends JodaDateDeserializerBase<Instant>
{
private static final long serialVersionUID = 1L;
public InstantDeserializer() {
super(Instant.class);
this(FormatConfig.DEFAULT_DATETIME_PARSER);
}
public InstantDeserializer(JacksonJodaDateFormat format) {
super(Instant.class, format);
}
@Override
public JodaDateDeserializerBase<?> withFormat(JacksonJodaDateFormat format) {
return new InstantDeserializer(format);
}
@Override
......@@ -34,7 +45,9 @@ public class InstantDeserializer
if (str.length() == 0) {
return null;
}
return new Instant(str);
// 11-Sep-2018, tatu: `DateTimeDeserializer` allows timezone inclusion in brackets;
// should that be checked here too?
return Instant.parse(str, _format.createParser(ctxt));
}
return _handleNotNumberOrString(p, ctxt);
}
......
......@@ -2,6 +2,8 @@ package com.fasterxml.jackson.datatype.joda.deser;
import java.io.IOException;
import com.fasterxml.jackson.datatype.joda.cfg.FormatConfig;
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat;
import org.joda.time.MonthDay;
import com.fasterxml.jackson.core.JsonParser;
......@@ -13,13 +15,21 @@ import com.fasterxml.jackson.databind.DeserializationContext;
* <p>
* Expects a string value compatible with MonthDay's parse operation.
*/
public class MonthDayDeserializer extends JodaDeserializerBase<MonthDay>
public class MonthDayDeserializer extends JodaDateDeserializerBase<MonthDay>
{
private static final long serialVersionUID = 1L;
public MonthDayDeserializer()
{
super(MonthDay.class);
public MonthDayDeserializer() {
this(FormatConfig.DEFAULT_MONTH_DAY_FORMAT);
}
public MonthDayDeserializer(JacksonJodaDateFormat format) {
super(MonthDay.class, format);
}
@Override
public JodaDateDeserializerBase<?> withFormat(JacksonJodaDateFormat format) {
return new MonthDayDeserializer(format);
}
@Override
......@@ -32,7 +42,7 @@ public class MonthDayDeserializer extends JodaDeserializerBase<MonthDay>
if (str.isEmpty()) {
return getNullValue(ctxt);
}
return MonthDay.parse(str);
return MonthDay.parse(str, this._format.createParser(ctxt));
}
return (MonthDay) ctxt.handleUnexpectedToken(handledType(), p.getCurrentToken(), p,
"expected JSON String");
......
......@@ -2,6 +2,8 @@ package com.fasterxml.jackson.datatype.joda.deser;
import java.io.IOException;
import com.fasterxml.jackson.datatype.joda.cfg.FormatConfig;
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat;
import org.joda.time.YearMonth;
import com.fasterxml.jackson.core.JsonParser;
......@@ -13,13 +15,21 @@ import com.fasterxml.jackson.databind.DeserializationContext;
* <p>
* Expects a string value compatible with YearMonth's parse operation.
*/
public class YearMonthDeserializer extends JodaDeserializerBase<YearMonth>
public class YearMonthDeserializer extends JodaDateDeserializerBase<YearMonth>
{
private static final long serialVersionUID = 1L;
public YearMonthDeserializer()
{
super(YearMonth.class);
public YearMonthDeserializer() {
this(FormatConfig.DEFAULT_YEAR_MONTH_FORMAT);
}
public YearMonthDeserializer(JacksonJodaDateFormat format) {
super(YearMonth.class, format);
}
@Override
public JodaDateDeserializerBase<?> withFormat(JacksonJodaDateFormat format) {
return new YearMonthDeserializer(format);
}
@Override
......@@ -31,7 +41,7 @@ public class YearMonthDeserializer extends JodaDeserializerBase<YearMonth>
if (str.isEmpty()) {
return null;
}
return YearMonth.parse(str);
return YearMonth.parse(str, _format.createParser(ctxt));
}
return (YearMonth) ctxt.handleUnexpectedToken(handledType(), p.getCurrentToken(), p,
"expected JSON String");
......
......@@ -25,6 +25,10 @@ public class DateMidnightSerializer
this(FormatConfig.DEFAULT_LOCAL_DATEONLY_FORMAT, 0);
}
public DateMidnightSerializer(JacksonJodaDateFormat format) {
this(format, 0);
}
public DateMidnightSerializer(JacksonJodaDateFormat format,
int shapeOverride) {
// true -> use arrays
......
......@@ -19,6 +19,10 @@ public class DateTimeSerializer
this(FormatConfig.DEFAULT_DATETIME_PRINTER, 0);
}
public DateTimeSerializer(JacksonJodaDateFormat format) {
this(format, 0);
}
public DateTimeSerializer(JacksonJodaDateFormat format,
int shapeOverride) {
// false -> no arrays (numbers)
......
......@@ -24,6 +24,11 @@ public class DurationSerializer // non final since 2.6.1
// it as container for numeric/textual distinction
public DurationSerializer() { this(FormatConfig.DEFAULT_DATEONLY_FORMAT, 0); }
public DurationSerializer(JacksonJodaDateFormat format) {
this(format, 0);
}
public DurationSerializer(JacksonJodaDateFormat formatter,
int shapeOverride) {
// false -> no arrays (numbers)
......
......@@ -15,8 +15,11 @@ public class InstantSerializer // non final since 2.6.1
{
private static final long serialVersionUID = 1L;
// NOTE: formatter not used for printing at all, hence choice doesn't matter
public InstantSerializer() { this(FormatConfig.DEFAULT_TIMEONLY_FORMAT, 0); }
public InstantSerializer() { this(FormatConfig.DEFAULT_DATETIME_PRINTER, 0); }
public InstantSerializer(JacksonJodaDateFormat format) {
this(format, 0);
}
public InstantSerializer(JacksonJodaDateFormat format,
int shapeOverride) {
super(Instant.class, format, SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
......@@ -40,7 +43,7 @@ public class InstantSerializer // non final since 2.6.1
throws IOException
{
if (_serializationShape(provider) == FORMAT_STRING) {
gen.writeString(value.toString());
gen.writeString(_format.createFormatter(provider).print(value));
} else {
gen.writeNumber(value.getMillis());
}
......
......@@ -17,6 +17,9 @@ public class IntervalSerializer extends JodaDateSerializerBase<Interval>
private static final long serialVersionUID = 1L;
public IntervalSerializer() { this(FormatConfig.DEFAULT_DATETIME_PRINTER, 0); }
public IntervalSerializer(JacksonJodaDateFormat format) {
this(format, 0);
}
public IntervalSerializer(JacksonJodaDateFormat format,
int shapeOverride) {
super(Interval.class, format, SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS,
......
......@@ -17,12 +17,17 @@ public class LocalDateSerializer // non final since 2.6.1
private static final long serialVersionUID = 1L;
public LocalDateSerializer() { this(FormatConfig.DEFAULT_LOCAL_DATEONLY_FORMAT, 0); }
public LocalDateSerializer(JacksonJodaDateFormat format) {
this(format, 0);
}
public LocalDateSerializer(JacksonJodaDateFormat format,
int shapeOverride) {
super(LocalDate.class, format, SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
FORMAT_ARRAY, shapeOverride);
}
@Override
public LocalDateSerializer withFormat(JacksonJodaDateFormat formatter,
int shapeOverride) {
......
......@@ -16,12 +16,16 @@ public class LocalDateTimeSerializer // non final since 2.6.1
private static final long serialVersionUID = 1L;
public LocalDateTimeSerializer() { this(FormatConfig.DEFAULT_LOCAL_DATETIME_PRINTER, 0); }
public LocalDateTimeSerializer(JacksonJodaDateFormat format) {
this(format, 0);
}
public LocalDateTimeSerializer(JacksonJodaDateFormat format,
int shapeOverride) {
super(LocalDateTime.class, format, SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
FORMAT_ARRAY, shapeOverride);
}
@Override
public LocalDateTimeSerializer withFormat(JacksonJodaDateFormat formatter,
int shapeOverride) {
......
......@@ -19,6 +19,11 @@ public class LocalTimeSerializer // non final since 2.6.1
public LocalTimeSerializer() {
this(FormatConfig.DEFAULT_LOCAL_TIMEONLY_PRINTER, 0);
}
public LocalTimeSerializer(JacksonJodaDateFormat format) {
this(format, 0);
}
public LocalTimeSerializer(JacksonJodaDateFormat format,
int shapeOverride) {
super(LocalTime.class, format, SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
......
package com.fasterxml.jackson.datatype.joda.ser;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.datatype.joda.cfg.FormatConfig;
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat;
import org.joda.time.MonthDay;
import java.io.IOException;
public class MonthDaySerializer extends JodaDateSerializerBase<MonthDay>
{
private static final long serialVersionUID = 1L;
public MonthDaySerializer() { this(FormatConfig.DEFAULT_MONTH_DAY_FORMAT, 0); }
public MonthDaySerializer(JacksonJodaDateFormat format) {
this(format, 0);
}
public MonthDaySerializer(JacksonJodaDateFormat format,
int shapeOverride) {
super(MonthDay.class, format, SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
FORMAT_STRING, shapeOverride);
}
@Override
public MonthDaySerializer withFormat(JacksonJodaDateFormat formatter,
int shapeOverride) {
return new MonthDaySerializer(formatter, shapeOverride);
}
@Override
public void serialize(MonthDay value, JsonGenerator gen, SerializerProvider provider) throws IOException
{
gen.writeString(_format.createFormatter(provider).print(value));
}
}
package com.fasterxml.jackson.datatype.joda.ser;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.datatype.joda.cfg.FormatConfig;
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat;
import org.joda.time.YearMonth;
import java.io.IOException;
public class YearMonthSerializer extends JodaDateSerializerBase<YearMonth>
{
private static final long serialVersionUID = 1L;
public YearMonthSerializer() { this(FormatConfig.DEFAULT_YEAR_MONTH_FORMAT, 0); }
public YearMonthSerializer(JacksonJodaDateFormat format) {
this(format, 0);
}
public YearMonthSerializer(JacksonJodaDateFormat format,
int shapeOverride) {
super(YearMonth.class, format, SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
FORMAT_STRING, shapeOverride);
}
@Override
public YearMonthSerializer withFormat(JacksonJodaDateFormat formatter,
int shapeOverride) {
return new YearMonthSerializer(formatter, shapeOverride);
}
@Override
public void serialize(YearMonth value, JsonGenerator gen, SerializerProvider provider) throws IOException
{
gen.writeString(_format.createFormatter(provider).print(value));
}
}
package com.fasterxml.jackson.datatype.joda;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import junit.framework.TestCase;
import java.io.IOException;
import java.util.Arrays;
import org.joda.time.Instant;
import org.joda.time.YearMonth;
import org.joda.time.MonthDay;
import static org.junit.Assert.*;
public abstract class JodaTestBase extends TestCase
{
protected static ObjectMapper jodaMapper()
{
protected static class FormattedInstant {
@JsonFormat(pattern = "dd/MM/yyyy HH_mm_ss_SSS")
public Instant value;
public FormattedInstant(Instant v) { value = v; }
protected FormattedInstant() { }
}
protected static class FormattedYearMonth {
@JsonFormat(pattern = "yyyy/MM")
public YearMonth value;
public FormattedYearMonth(YearMonth v) { value = v; }
protected FormattedYearMonth() { }
}
protected static class FormattedMonthDay {
@JsonFormat(pattern = "MM:dd")
public MonthDay value;
public FormattedMonthDay(MonthDay v) { value = v; }
protected FormattedMonthDay() { }
}
// Mix-in class for forcing polymorphic handling
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.WRAPPER_ARRAY)
protected static interface MixinForPolymorphism {
}
/*
/**********************************************************
/* Factory methods
/**********************************************************
*/
protected static ObjectMapper jodaMapper() {
return new JodaMapper();
}
......
package com.fasterxml.jackson.datatype.joda;
package com.fasterxml.jackson.datatype.joda.depr;
import java.io.IOException;
import java.util.TimeZone;
......@@ -8,7 +8,9 @@ import org.joda.time.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.joda.JodaTestBase;
@SuppressWarnings("deprecation") // because DateMidnight deprecated by Joda
public class DateMidnightTest extends JodaTestBase
......@@ -48,7 +50,7 @@ public class DateMidnightTest extends JodaTestBase
/*
/**********************************************************
/* Test methods
/* Test methods, deserialization
/**********************************************************
*/
......@@ -119,7 +121,48 @@ public class DateMidnightTest extends JodaTestBase
assertEquals(13, date2.getDayOfMonth());
}
public void testCustomFormat() throws Exception
/*
/**********************************************************
/* Test methods, serialization
/**********************************************************
*/
public void testSerializeAsTimestamp() throws Exception
{
assertEquals(aposToQuotes("{'value':0}"),
MAPPER.writeValueAsString(new FormattedDateAsTimestamp(
new DateMidnight(0, DateTimeZone.UTC))));
}
public void testDateMidnightSer() throws IOException
{
ObjectMapper mapper = jodaMapper()
.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.enable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS);
final ObjectWriter writer = mapper.writer();
DateMidnight date = new DateMidnight(2001, 5, 25);
// default format is that of JSON array...
assertEquals("[2001,5,25]", writer.writeValueAsString(date));
// but we can force it to be a String as well (note: here we assume this is
// dynamically changeable)
assertEquals(quote("2001-05-25"),
writer.without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.writeValueAsString(date));
mapper = jodaMapper();
mapper.addMixIn(DateMidnight.class, MixInForTypeId.class);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
assertEquals("[\"org.joda.time.DateMidnight\",\"2001-05-25\"]", mapper.writeValueAsString(date));
}
/*
/**********************************************************
/* Test methods, custom format
/**********************************************************
*/
public void testDeserWithCustomFormat() throws Exception
{
String STR = "2015-06-19";
String ALT = "19.06.2015";
......@@ -159,10 +202,4 @@ public class DateMidnightTest extends JodaTestBase
assertEquals("America/New_York", resultTz.getID());
}
public void testSerializeAsTimestamp() throws Exception
{
assertEquals(aposToQuotes("{'value':0}"),
MAPPER.writeValueAsString(new FormattedDateAsTimestamp(
new DateMidnight(0, DateTimeZone.UTC))));
}
}
......@@ -9,16 +9,11 @@ import org.joda.time.DateTime;
import org.joda.time.Instant;
import org.joda.time.ReadableInstant;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.joda.JodaTestBase;
public class InstantDeserTest extends JodaTestBase
{
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.WRAPPER_ARRAY)
private static interface ObjectConfiguration {
}
/*
/**********************************************************
/* Test methods
......@@ -35,11 +30,12 @@ public class InstantDeserTest extends JodaTestBase
assertNull(MAPPER.readValue(quote(""), ReadableInstant.class));
}
public void testDeserDateTimeWithTypeInfo() throws IOException
public void testDeserInstantWithTypeInfo() throws IOException
{
ObjectMapper mapper = jodaMapper();
mapper.addMixIn(DateTime.class, ObjectConfiguration.class);
DateTime date = mapper.readValue("[\"org.joda.time.DateTime\",\"1972-12-28T12:00:01.000+0000\"]", DateTime.class);
mapper.addMixIn(Instant.class, MixinForPolymorphism.class);
Instant date = mapper.readValue("[\"org.joda.time.Instant\",\"1972-12-28T12:00:01.000+0000\"]",
Instant.class);
assertNotNull(date);
assertEquals("1972-12-28T12:00:01.000Z", date.toString());
}
......@@ -61,7 +57,16 @@ public class InstantDeserTest extends JodaTestBase
assertNotNull(date);
assertEquals("1972-12-28T12:00:01.000Z", date.toString());
// since 1.6.1, for [JACKSON-360]
assertNull(MAPPER.readValue(quote(""), Instant.class));
}
public void testDeserInstantCustomFormat() throws IOException
{
FormattedInstant input = MAPPER.readValue(aposToQuotes(
"{'value':'28/12/1972 12_34_56_789'}"),
FormattedInstant.class);
DateTime date = input.value.toDateTime();
assertEquals(1972, date.getYear());
assertEquals(789, date.getMillisOfSecond());
}
}
......@@ -19,12 +19,6 @@ public class IntervalDeserTest extends JodaTestBase
private final ObjectMapper MAPPER = jodaMapper();
/*
/**********************************************************
/* Test methods
/**********************************************************
*/
/*
/**********************************************************
/* Tests for Interval type
......@@ -46,20 +40,19 @@ public class IntervalDeserTest extends JodaTestBase
public void testIntervalDeserWithTimeZone() throws IOException