Skip to content

Modify java generator to not use joda time anymore.#27

Open
sbrossie wants to merge 1 commit intomasterfrom
joda-removal
Open

Modify java generator to not use joda time anymore.#27
sbrossie wants to merge 1 commit intomasterfrom
joda-removal

Conversation

@sbrossie
Copy link
Member

Summary of Joda Removal Changes for Generator Update:

  1. Type Mapping Changes (the core generator change) The generator needs to update its type mappings for date/time types:

Swagger Type Old Java Type New Java Type
date-time org.joda.time.DateTime java.time.ZonedDateTime date org.joda.time.LocalDate java.time.LocalDate
This is a global find-and-replace in the generator's type map. Every place the generator emits DateTime (from Joda), it should emit ZonedDateTime instead. LocalDate keeps the same class name but moves from org.joda.time to java.time.

  1. Import Changes Old Import New Import
    import org.joda.time.DateTime; import java.time.ZonedDateTime; import org.joda.time.LocalDate; import java.time.LocalDate;
  2. Affected Generated Code Locations Model classes (model/gen/) — 16 files affected. Every field, constructor parameter, getter, and setter that used DateTime now uses ZonedDateTime. Files using only LocalDate (Invoice, InvoiceDryRun) just had the import change. No behavioral/structural changes — it's purely a type substitution.

API classes (api/gen/) — 6 files affected. Method parameter types changed from DateTime → ZonedDateTime and imports changed from org.joda.time.* → java.time.*. The method bodies (query parameter serialization via String.valueOf(...)) are unchanged.

  1. Non-Generated (Manual) Changes — FYI only These are not generator concerns but relevant context:

pom.xml: Replaced jackson-datatype-joda dependency with jackson-datatype-jsr310. Removed the joda-time dependency entirely. KillBillHttpClient.java: Changed JodaModule → JavaTimeModule, added mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS). CatalogVersions.java and DateTimes.java: Changed ArrayList → ArrayList (these are hand-maintained wrapper types).
5. Generator Change Checklist In the type mapping configuration, change the mapping for the date-time swagger format from org.joda.time.DateTime to java.time.ZonedDateTime In the type mapping configuration, change the mapping for the date swagger format from org.joda.time.LocalDate to java.time.LocalDate In the import mapping configuration, replace org.joda.time.DateTime → java.time.ZonedDateTime and org.joda.time.LocalDate → java.time.LocalDate No template/mustache changes needed — the transformation is purely at the type/import mapping level

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Kill Bill Java code generator to migrate from Joda Time to Java Time API (JSR-310) for date and date-time types. The generator is part of a Swagger Codegen extension that produces client library code for Kill Bill.

Changes:

  • Updated type mappings to use java.time.ZonedDateTime instead of org.joda.time.DateTime and java.time.LocalDate instead of org.joda.time.LocalDate
  • Updated import mappings to reference java.time package instead of org.joda.time
  • Added special handling for ZonedDateTime arrays to use the existing DateTimes wrapper class

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Summary of Joda Removal Changes for Generator Update
1. Type Mapping Changes (the core generator change)
The generator needs to update its type mappings for date/time types:

Swagger Type	Old Java Type	New Java Type
date-time	org.joda.time.DateTime	java.time.ZonedDateTime
date	org.joda.time.LocalDate	java.time.LocalDate
This is a global find-and-replace in the generator's type map. Every place the generator emits DateTime (from Joda), it should emit ZonedDateTime instead. LocalDate keeps the same class name but moves from org.joda.time to java.time.

2. Import Changes
Old Import	New Import
import org.joda.time.DateTime;	import java.time.ZonedDateTime;
import org.joda.time.LocalDate;	import java.time.LocalDate;
3. Affected Generated Code Locations
Model classes (model/gen/) — 16 files affected. Every field, constructor parameter, getter, and setter that used DateTime now uses ZonedDateTime. Files using only LocalDate (Invoice, InvoiceDryRun) just had the import change. No behavioral/structural changes — it's purely a type substitution.

API classes (api/gen/) — 6 files affected. Method parameter types changed from DateTime → ZonedDateTime and imports changed from org.joda.time.* → java.time.*. The method bodies (query parameter serialization via String.valueOf(...)) are unchanged.

4. Non-Generated (Manual) Changes — FYI only
These are not generator concerns but relevant context:

pom.xml: Replaced jackson-datatype-joda dependency with jackson-datatype-jsr310. Removed the joda-time dependency entirely.
KillBillHttpClient.java: Changed JodaModule → JavaTimeModule, added mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).
CatalogVersions.java and DateTimes.java: Changed ArrayList<DateTime> → ArrayList<ZonedDateTime> (these are hand-maintained wrapper types).
5. Generator Change Checklist
In the type mapping configuration, change the mapping for the date-time swagger format from org.joda.time.DateTime to java.time.ZonedDateTime
In the type mapping configuration, change the mapping for the date swagger format from org.joda.time.LocalDate to java.time.LocalDate
In the import mapping configuration, replace org.joda.time.DateTime → java.time.ZonedDateTime and org.joda.time.LocalDate → java.time.LocalDate
No template/mustache changes needed — the transformation is purely at the type/import mapping level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants