当前位置: 首页>>代码示例>>Java>>正文


Java StdDateFormat类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.util.StdDateFormat的典型用法代码示例。如果您正苦于以下问题:Java StdDateFormat类的具体用法?Java StdDateFormat怎么用?Java StdDateFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StdDateFormat类属于com.fasterxml.jackson.databind.util包,在下文中一共展示了StdDateFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupMapper

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
private static void setupMapper(ObjectMapper mapper) {
	// Serialize dates using ISO8601 format
	// Jackson uses timestamps by default, so use StdDateFormat to get ISO8601
	mapper.getSerializationConfig().with(new StdDateFormat());
	// Deserialize dates using ISO8601 format
	mapper.getDeserializationConfig().with(new StdDateFormat());
	// Prevent exceptions from being thrown for unknown properties
	// mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
	// false);
	mapper.addHandler(new DeserializationProblemHandler() {
		@Override
		public boolean handleUnknownProperty(DeserializationContext ctxt, JsonParser jp, JsonDeserializer<?> deserializer, Object beanOrClass, String propertyName) throws IOException,
				JsonProcessingException {
			return true;
		}
	});
	// ignore fields with null values
	mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:20,代码来源:JacksonHelper.java

示例2: Shogun2JsonObjectMapper

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
/**
 * Constructor
 */
public Shogun2JsonObjectMapper() {
	super();

	// register the joda module to support the joda time types, which are
	// used in shogun
	this.registerModule(new JodaModule());

	// register JTS geometry types
	this.registerModule(new JtsModule());

	// StdDateFormat is ISO8601 since jackson 2.9
	configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
	setDateFormat(new StdDateFormat());
	setTimeZone(TimeZone.getDefault());
}
 
开发者ID:terrestris,项目名称:shogun2,代码行数:19,代码来源:Shogun2JsonObjectMapper.java

示例3: deserialize

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonNode tree = jp.readValueAsTree();
    if (tree.isPojo()) {
        POJONode pojoNode = (POJONode) tree;
        Object pojo = pojoNode.getPojo();

        if (pojo instanceof Date) {
            return (Date) pojoNode.getPojo();
        } else {
            throw new RuntimeException("unsupported date type, expected: " + Date.class.getName());
        }
    }
    String stringDate = tree.asText();
    StdDateFormat stdDateFormat = new StdDateFormat();
    try {
        return stdDateFormat.parse(stringDate);
    } catch (ParseException e) {
        throw Throwables.propagate(e);
    }

}
 
开发者ID:jmingo-projects,项目名称:jmingo,代码行数:26,代码来源:MongoDateDeserializer.java

示例4: with

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
/**
 * Fluent factory for constructing a new instance that uses specified TimeZone.
 * Note that timezone used with also be assigned to configured {@link DateFormat},
 * changing time formatting defaults.
 */
public BaseSettings with(TimeZone tz)
{
    if (tz == null) {
        throw new IllegalArgumentException();
    }
    DateFormat df = _dateFormat;
    if (df instanceof StdDateFormat) {
        df = ((StdDateFormat) df).withTimeZone(tz);
    } else {
        // we don't know if original format might be shared; better create a clone:
        df = (DateFormat) df.clone();
        df.setTimeZone(tz);
    }
    return new BaseSettings(_classIntrospector, _annotationIntrospector,
            _visibilityChecker, _propertyNamingStrategy, _typeFactory,
            _typeResolverBuilder, df, _handlerInstantiator, _locale,
            tz, _defaultBase64);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:24,代码来源:BaseSettings.java

示例5: ApacheHttpTransport

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
public ApacheHttpTransport(HttpClient httpClient, Crypto crypto, ObjectMapper objectMapper,
                           Cache publicKeyCache, String baseUrl, EntityIdentifier issuer,
                           JWTService jwtService, JWEService jweService,
                           int offsetTTL, int currentPublicKeyTTL, EntityKeyMap entityKeyMap
) {
    this.objectMapper = objectMapper;
    this.objectMapper.setDateFormat(new StdDateFormat());
    this.crypto = crypto;
    this.httpClient = httpClient;
    this.jwtService = jwtService;
    this.jweService = jweService;
    this.publicKeyCache = publicKeyCache;
    this.entityKeyMap = entityKeyMap;
    this.offsetTTL = offsetTTL;
    this.currentPublicKeyTTL = currentPublicKeyTTL;
    this.issuer = issuer;
    logger = LogFactory.getLog(getClass());
    rbf = new ApiRequestBuilderFactory(issuer.toString(), baseUrl, objectMapper, crypto, jwtService, jweService);
}
 
开发者ID:iovation,项目名称:launchkey-java,代码行数:20,代码来源:ApacheHttpTransport.java

示例6: parseDateToMillisecs

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
private static long parseDateToMillisecs(String valueAsText) {

        try {
            return Long.parseLong(valueAsText);
        } catch (NumberFormatException nfe) {
            try {
                return new StdDateFormat().parse(valueAsText).getTime();
            } catch (ParseException pe) {
                throw new IllegalArgumentException("Unable to parse this string as a date: " + valueAsText);
            }
        }

    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:DefaultRule.java

示例7: noCustomDateFormat

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
@Test
public void noCustomDateFormat() throws Exception {
	this.context.register(JacksonAutoConfiguration.class);
	this.context.refresh();
	ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
	assertThat(mapper.getDateFormat()).isInstanceOf(StdDateFormat.class);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:JacksonAutoConfigurationTests.java

示例8: WebServiceClient

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
private WebServiceClient(WebServiceClient.Builder builder) {
    host = builder.host;
    port = builder.port;
    useHttps = builder.useHttps;
    locales = builder.locales;
    licenseKey = builder.licenseKey;
    userId = builder.userId;

    mapper = new ObjectMapper();
    mapper.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    mapper.setDateFormat(new StdDateFormat().withColonInTimeZone(true));

    RequestConfig.Builder configBuilder = RequestConfig.custom()
            .setConnectTimeout(builder.connectTimeout)
            .setSocketTimeout(builder.readTimeout);

    if (builder.proxy != null && builder.proxy != Proxy.NO_PROXY) {
        InetSocketAddress address = (InetSocketAddress) builder.proxy.address();
        HttpHost proxyHost = new HttpHost(address.getHostName(), address.getPort());
        configBuilder.setProxy(proxyHost);
    }

    RequestConfig config = configBuilder.build();
    httpClient =
            HttpClientBuilder.create()
                    .setUserAgent(userAgent())
                    .setDefaultRequestConfig(config).build();
}
 
开发者ID:maxmind,项目名称:minfraud-api-java,代码行数:30,代码来源:WebServiceClient.java

示例9: toJson

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
/**
 * @return JSON representation of this object.
 * @throws IOException if there is an error serializing the object to JSON.
 */
public final String toJson() throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
    mapper.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
    mapper.setDateFormat(new StdDateFormat().withColonInTimeZone(true));
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);

    return mapper.writeValueAsString(this);
}
 
开发者ID:maxmind,项目名称:minfraud-api-java,代码行数:16,代码来源:AbstractModel.java

示例10: parseDateToMillisecs

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
private long parseDateToMillisecs(String valueAsText) {

        try {
            return Long.parseLong(valueAsText);
        } catch (NumberFormatException nfe) {
            try {
                return new StdDateFormat().parse(valueAsText).getTime();
            } catch (ParseException pe) {
                throw new IllegalArgumentException("Unable to parse this string as a date: " + valueAsText);
            }
        }

    }
 
开发者ID:bacta,项目名称:jsonschema2pojo-bacta,代码行数:14,代码来源:SoeDefaultRule.java

示例11: noCustomDateFormat

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
@Test
public void noCustomDateFormat() throws Exception {
	this.context.register(JacksonAutoConfiguration.class);
	this.context.refresh();
	ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
	assertThat(mapper.getDateFormat(), is(instanceOf(StdDateFormat.class)));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:8,代码来源:JacksonAutoConfigurationTests.java

示例12: createObjectMapper

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
private static ObjectMapper createObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new Jdk8Module());
    mapper.registerModule(new JavaTimeModule());
    mapper.registerModule(new AfterburnerModule());
    mapper.setDateFormat(new StdDateFormat());
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, true);
    mapper.setAnnotationIntrospector(new JSONAnnotationIntrospector());
    return mapper;
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:13,代码来源:JSONMapper.java

示例13: with

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
public final BaseSettings with(TimeZone paramTimeZone)
{
  if (paramTimeZone == null)
    throw new IllegalArgumentException();
  DateFormat localDateFormat1 = this._dateFormat;
  Object localObject;
  if ((localDateFormat1 instanceof StdDateFormat))
  {
    localObject = ((StdDateFormat)localDateFormat1).withTimeZone(paramTimeZone);
  }
  else
  {
    DateFormat localDateFormat2 = (DateFormat)localDateFormat1.clone();
    localObject = localDateFormat2;
    localDateFormat2.setTimeZone(paramTimeZone);
  }
  ClassIntrospector localClassIntrospector = this._classIntrospector;
  AnnotationIntrospector localAnnotationIntrospector = this._annotationIntrospector;
  VisibilityChecker localVisibilityChecker = this._visibilityChecker;
  PropertyNamingStrategy localPropertyNamingStrategy = this._propertyNamingStrategy;
  TypeFactory localTypeFactory = this._typeFactory;
  TypeResolverBuilder localTypeResolverBuilder = this._typeResolverBuilder;
  HandlerInstantiator localHandlerInstantiator = this._handlerInstantiator;
  Locale localLocale = this._locale;
  Base64Variant localBase64Variant = this._defaultBase64;
  return new BaseSettings(localClassIntrospector, localAnnotationIntrospector, localVisibilityChecker, localPropertyNamingStrategy, localTypeFactory, localTypeResolverBuilder, (DateFormat)localObject, localHandlerInstantiator, localLocale, paramTimeZone, localBase64Variant);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:28,代码来源:BaseSettings.java

示例14: testDateFormat

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
/**
 * Tests whether the dateFormat is ISO8601
 */
@Test
public void testDateFormat() {

	SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
	DeserializationConfig deserializationConfig = objectMapper.getDeserializationConfig();

	DateFormat serializationDateFormat = serializationConfig.getDateFormat();
	DateFormat deserializationDateFormat = deserializationConfig.getDateFormat();

	assertThat(serializationDateFormat, instanceOf(StdDateFormat.class));
	assertThat(deserializationDateFormat, instanceOf(StdDateFormat.class));
}
 
开发者ID:terrestris,项目名称:shogun2,代码行数:16,代码来源:Shogun2JsonObjectMapperTest.java

示例15: StenoEncoder

import com.fasterxml.jackson.databind.util.StdDateFormat; //导入依赖的package包/类
StenoEncoder(final JsonFactory jsonFactory, final ObjectMapper objectMapper) {

        // Initialize object mapper;
        _objectMapper = objectMapper;
        _objectMapper.setAnnotationIntrospector(new StenoAnnotationIntrospector(_objectMapper));
        final SimpleFilterProvider simpleFilterProvider = new SimpleFilterProvider();
        simpleFilterProvider.addFilter(RedactionFilter.REDACTION_FILTER_ID, new RedactionFilter(!DEFAULT_REDACT_NULL));
        // Initialize this here based on the above code, if it was initialized at the declaration site then things
        // could get out of sync
        _redactEnabled = true;
        _objectMapper.setFilterProvider(simpleFilterProvider);

        // Setup writing of Date/DateTime values
        _objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        _objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
        _objectMapper.setDateFormat(new StdDateFormat());

        // Simple module with customizations
        final SimpleModule module = new SimpleModule();
        module.setSerializerModifier(new StenoBeanSerializerModifier(this));
        _objectMapper.registerModule(module);

        // Throwable mix-in
        _objectMapper.setMixIns(Collections.singletonMap(Throwable.class, ThrowableMixIn.class));

        // After burner to improve data-bind performance
        _objectMapper.registerModule(new AfterburnerModule());

        // Serialization strategies
        _listsSerialziationStrategy = new ListsSerialziationStrategy(this, jsonFactory, _objectMapper);
        _objectAsJsonSerialziationStrategy = new ObjectAsJsonSerialziationStrategy(this, jsonFactory, _objectMapper);
        _objectSerialziationStrategy = new ObjectSerialziationStrategy(this, jsonFactory, _objectMapper);
        _mapOfJsonSerialziationStrategy = new MapOfJsonSerialziationStrategy(this, jsonFactory, _objectMapper);
        _mapSerialziationStrategy = new MapSerialziationStrategy(this, jsonFactory, _objectMapper);
        _arrayOfJsonSerialziationStrategy = new ArrayOfJsonSerialziationStrategy(this, jsonFactory, _objectMapper);
        _arraySerialziationStrategy = new ArraySerialziationStrategy(this, jsonFactory, _objectMapper);
        _standardSerializationStrategy = new StandardSerializationStrategy(this, jsonFactory, _objectMapper);
    }
 
开发者ID:ArpNetworking,项目名称:logback-steno,代码行数:39,代码来源:StenoEncoder.java


注:本文中的com.fasterxml.jackson.databind.util.StdDateFormat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。