Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Extension module to properly support full datatype set of Joda datetime library

License

NotificationsYou must be signed in to change notification settings

FasterXML/jackson-datatype-joda

Repository files navigation

Jackson datatype module (jar)to support JSON serialization (writing JSON) and deserialization (reading from JSON)ofJoda data types, such asDateTime.

Status

Build StatusMaven CentralJavadoc

Module has been production-ready since version 2.0, and offers relatively extensive support for Joda datatypes.Contributions are always welcome -- not all types are yet supported; and we may want to support even wider alternativeformats on input side.

License

Apache License 2.0

Usage

Since this module extends basicJackson databind functionality, you may want to check outdocumentation atJackson-docs first.

Maven dependency

To use module on Maven-based projects, use following dependency:

<dependency>  <groupId>com.fasterxml.jackson.datatype</groupId>  <artifactId>jackson-datatype-joda</artifactId>  <version>3.0.0-SNAPSHOT</version></dependency>

(or whatever version is most up-to-date at the moment)

Registering module

To use Joda datatypes with Jackson, you will first need to register the module first (same aswith all Jackson datatype modules):

ObjectMappermapper =JsonMapper.builder().addModule(newJodaModule()).build();

Using older style (that is being phased out):

ObjectMappermapper =newObjectMapper();mapper.registerModule(newJodaModule());

Reading and Writing Joda types

After registering Joda module,Jackson Databind will be able to write valuesof supported Joda types as JSON (and other formats Jackson supports), and read Joda valuesfrom same formats.

With JSON, for example, following would work

publicclassBean {publicDateTimestart;}finalStringINPUT_JSON ="{\"start\" :\"1972-12-28T12:00:01.000Z\"}";Beanbean =mapper.readValue(INPUT_JSON,Bean.class);

and propertystart of Bean would have expectedDateTime value.

Conversely, you can produce JSON (and other supported formats) simply with:

Stringjson =mapper.writeValueAsString(bean);Assert.assertEquals(INPUT_JSON,json);

Compatibility

Module works with Joda version 2.10 (as of Jackson 3.0) and higher (CI tests compatibility since module version 2.14), even if it declares dependency to a newer version.This means that it is possible to use with older version by using Maven dependency override.

More

SeeWiki for more information (javadocs, downloads).

About

Extension module to properly support full datatype set of Joda datetime library

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors38


[8]ページ先頭

©2009-2025 Movatter.jp