/** * @since 2.5 */ public DateFormat getDateFormat() { // arbitrary choice but let's do: return _serializationConfig.getDateFormat(); }
protected final DateFormat _dateFormat() { if (_dateFormat != null) { return _dateFormat; } /* At this point, all timezone configuration should have occurred, with respect * to default dateformat configuration. But we still better clone * an instance as formatters are stateful, not thread-safe. */ DateFormat df = _config.getDateFormat(); _dateFormat = df = (DateFormat) df.clone(); // [databind#939]: 26-Sep-2015, tatu: With 2.6, formatter has been (pre)configured // with TimeZone, so we should NOT try overriding it unlike with earlier versions /* TimeZone tz = getTimeZone(); if (tz != df.getTimeZone()) { df.setTimeZone(tz); } */ return df; } }
@Test public void simpleDateFormatStringSetter() { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().simpleDateFormat(DATE_FORMAT).build(); assertEquals(dateFormat, objectMapper.getSerializationConfig().getDateFormat()); assertEquals(dateFormat, objectMapper.getDeserializationConfig().getDateFormat()); }
@Test public void dateTimeFormatSetter() { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().dateFormat(dateFormat).build(); assertEquals(dateFormat, objectMapper.getSerializationConfig().getDateFormat()); assertEquals(dateFormat, objectMapper.getDeserializationConfig().getDateFormat()); }
DateFormat df0 = serializers.getConfig().getDateFormat();
@Test public void setDateFormat() { this.factory.setDateFormat(this.dateFormat); this.factory.afterPropertiesSet(); assertEquals(this.dateFormat, this.factory.getObject().getSerializationConfig().getDateFormat()); assertEquals(this.dateFormat, this.factory.getObject().getDeserializationConfig().getDateFormat()); }
@Test public void setSimpleDateFormat() { this.factory.setSimpleDateFormat(DATE_FORMAT); this.factory.afterPropertiesSet(); assertEquals(this.dateFormat, this.factory.getObject().getSerializationConfig().getDateFormat()); assertEquals(this.dateFormat, this.factory.getObject().getDeserializationConfig().getDateFormat()); }
/** * @since 2.5 */ public DateFormat getDateFormat() { // arbitrary choice but let's do: return _serializationConfig.getDateFormat(); }
/** * @since 2.5 */ public DateFormat getDateFormat() { // arbitrary choice but let's do: return _serializationConfig.getDateFormat(); }
/** * @since 2.5 */ public DateFormat getDateFormat() { // arbitrary choice but let's do: return _serializationConfig.getDateFormat(); }
/** * @since 2.5 */ public DateFormat getDateFormat() { // arbitrary choice but let's do: return _serializationConfig.getDateFormat(); }
protected final DateFormat _dateFormat() { if (_dateFormat != null) { return _dateFormat; } /* 24-Feb-2012, tatu: At this point, all timezone configuration * should have occured, with respect to default dateformat * and timezone configuration. But we still better clone * an instance as formatters may be stateful. */ DateFormat df = _config.getDateFormat(); _dateFormat = df = (DateFormat) df.clone(); return df; } }
protected final DateFormat _dateFormat() { if (_dateFormat != null) { return _dateFormat; } /* 24-Feb-2012, tatu: At this point, all timezone configuration * should have occured, with respect to default dateformat * and timezone configuration. But we still better clone * an instance as formatters may be stateful. */ DateFormat df = _config.getDateFormat(); _dateFormat = df = (DateFormat) df.clone(); return df; } }
protected final DateFormat _dateFormat() { if (_dateFormat != null) { return _dateFormat; } /* 24-Feb-2012, tatu: At this point, all timezone configuration * should have occured, with respect to default dateformat * and timezone configuration. But we still better clone * an instance as formatters may be stateful. */ DateFormat df = _config.getDateFormat(); _dateFormat = df = (DateFormat) df.clone(); return df; } }
protected final DateFormat _dateFormat() { if (_dateFormat != null) { return _dateFormat; } /* 24-Feb-2012, tatu: At this point, all timezone configuration * should have occured, with respect to default dateformat * and timezone configuration. But we still better clone * an instance as formatters may be stateful. */ DateFormat df = _config.getDateFormat(); _dateFormat = df = (DateFormat) df.clone(); return df; } }
protected final DateFormat _dateFormat() { if (_dateFormat != null) { return _dateFormat; } /* At this point, all timezone configuration should have occured, with respect * to default dateformat configuration. But we still better clone * an instance as formatters are stateful, not thread-safe. */ DateFormat df = _config.getDateFormat(); _dateFormat = df = (DateFormat) df.clone(); // [databind#939]: 26-Sep-2015, tatu: With 2.6, formatter has been (pre)configured // with TimeZone, so we should NOT try overriding it unlike with earlier versions /* TimeZone tz = getTimeZone(); if (tz != df.getTimeZone()) { df.setTimeZone(tz); } */ return df; } }
protected final DateFormat _dateFormat() { if (_dateFormat != null) { return _dateFormat; } /* At this point, all timezone configuration should have occurred, with respect * to default dateformat configuration. But we still better clone * an instance as formatters are stateful, not thread-safe. */ DateFormat df = _config.getDateFormat(); _dateFormat = df = (DateFormat) df.clone(); // [databind#939]: 26-Sep-2015, tatu: With 2.6, formatter has been (pre)configured // with TimeZone, so we should NOT try overriding it unlike with earlier versions /* TimeZone tz = getTimeZone(); if (tz != df.getTimeZone()) { df.setTimeZone(tz); } */ return df; } }
@Override public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { DateFormat df = (DateFormat) provider.getConfig().getDateFormat().clone(); jgen.writeString(df.format(value)); }
DateFormat df = prov.getConfig().getDateFormat();
DateFormat df = prov.getConfig().getDateFormat();