Skip to content

pwall567/kjson-joda-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kjson-joda-time

Build Status License: MIT Kotlin Maven Central

Joda Time Adapters for kjson

Background

Prior to the release of Java 1.8, the Joda Time library provided data and time implementations superior to those available in the standard JDK. It has now become redundant, following the release of the java.time.xxx classes in JDK 1.8, but many applications still use the Joda Time libraries, and it is likely to be some time before all those older applications are converted or replaced.

The kjson-joda-time library provides custom serialization and deserialization classes to allow the use of the kjson library with applications that still use the Joda Time classes.

Quick Start

To use this library, add the conversions required to a JSONConfig within your application, as shown below:

    val config = JSONConfig {
        addJodaInstantFromJSON() // to deserialize org.joda.time.Instant
        addJodaInstantToJSON() // to serialize org.joda.time.Instant
        addJodaLocalTimeFromJSON() // to deserialize org.joda.time.LocalTime
        addJodaLocalTimeToJSON() // to serialize org.joda.time.LocalTime
        addJodaLocalDateFromJSON() // to deserialize org.joda.time.LocalDate
        addJodaLocalDateToJSON() // to serialize org.joda.time.LocalDate
        addJodaLocalDateTimeFromJSON() // to deserialize org.joda.time.LocalDateTime
        addJodaLocalDateTimeToJSON() // to serialize org.joda.time.LocalDateTime
        addJodaDateTimeFromJSON() // to deserialize org.joda.time.DateTime
        addJodaDateTimeToJSON() // to serialize org.joda.time.DateTime
        addJodaYearMonthFromJSON() // to deserialize org.joda.time.YearMonth
        addJodaYearMonthToJSON() // to serialize org.joda.time.YearMonth
        addJodaMonthDayFromJSON() // to deserialize org.joda.time.MonthDay
        addJodaMonthDayToJSON() // to serialize org.joda.time.MonthDay
    }

Alternatively, to include the entire set of conversions:

    val config = JSONConfig {
        combineAll(JodaTimeJSON.config)
    }

More Documentation to Follow

This is the initial release of the library; further classes and more documentation will be added later.

Dependency Specification

The latest version of the library is 0.4, and it may be obtained from the Maven Central repository.

Maven

    <dependency>
      <groupId>io.kjson</groupId>
      <artifactId>kjson-joda-time</artifactId>
      <version>0.4</version>
    </dependency>

Gradle

    implementation 'io.kjson:kjson-joda-time:0.4'

Gradle (kts)

    implementation("io.kjson:kjson-joda-time:0.4")

Peter Wall

2023-10-15

About

Joda Time Adapters for kjson

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages