{"id":16828532,"url":"https://github.com/pjfanning/jackson-module-scala-duration","last_synced_at":"2025-07-14T20:39:30.397Z","repository":{"id":40268266,"uuid":"478263541","full_name":"pjfanning/jackson-module-scala-duration","owner":"pjfanning","description":"Jackson support for scala durations","archived":false,"fork":false,"pushed_at":"2025-05-31T00:55:22.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-25T12:51:58.152Z","etag":null,"topics":["duration","jackson","jackson-module","scala","scala3"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pjfanning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"pjfanning"}},"created_at":"2022-04-05T19:01:02.000Z","updated_at":"2025-05-31T00:55:25.000Z","dependencies_parsed_at":"2024-05-07T19:25:32.698Z","dependency_job_id":"6b105d38-91a1-4484-9f0c-db8601488e3f","html_url":"https://github.com/pjfanning/jackson-module-scala-duration","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/pjfanning/jackson-module-scala-duration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjfanning%2Fjackson-module-scala-duration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjfanning%2Fjackson-module-scala-duration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjfanning%2Fjackson-module-scala-duration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjfanning%2Fjackson-module-scala-duration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pjfanning","download_url":"https://codeload.github.com/pjfanning/jackson-module-scala-duration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjfanning%2Fjackson-module-scala-duration/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265344892,"owners_count":23750571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["duration","jackson","jackson-module","scala","scala3"],"created_at":"2024-10-13T11:27:09.363Z","updated_at":"2025-07-14T20:39:30.387Z","avatar_url":"https://github.com/pjfanning.png","language":"Scala","funding_links":["https://github.com/sponsors/pjfanning"],"categories":[],"sub_categories":[],"readme":"# jackson-module-scala-duration\n\n![Build Status](https://github.com/pjfanning/jackson-module-scala-duration/actions/workflows/ci.yml/badge.svg)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.pjfanning/jackson-module-scala-duration_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.pjfanning/jackson-module-scala-duration_2.13)\n\nThis module needs to be used along with [jackson-datatype-jsr310](https://github.com/FasterXML/jackson-modules-java8/tree/2.16/datetime)\nJavaTimeModule. What this module does is to convert Scala [FiniteDurations](https://www.scala-lang.org/api/2.13.12/scala/concurrent/duration/FiniteDuration.html)\ninto Java Time [Durations](https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html) and vice versa.\nJavaTimeModule then does the rest.\n\nThis module supports Scala 2.11, 2.12, 2.13 and 3.\n\nIf you need to support Scala classes generally, you will also need to add [jackson-module-scala](https://github.com/FasterXML/jackson-module-scala).\n\nIf you don't use this module, Scala FiniteDurations can still be serialized but they will appear in a format like:\n\n```\n{\"length\":7,\"unit\":\"DAYS\",\"finite\":true}\n```\n\nThe format seems to differ depending on Scala version (because the internals of the FiniteDuration class can change\nfrom release to release). Deserialization seems to be problematic regardless of Scala version.\n\nWhen this module is used, the serialization format defaults to writing durations as numbers.\nThe format can be changed by enabling/disabling these jackson-datatype-jsr310 features:\n* SerializationFeature.WRITE_DATES_AS_TIMESTAMPS\n  * if you disable this, the format used is [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format (eg 'PT12H' for 12 hours) \n* SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS appears to have no effect on durations\n* DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS appears to have no effect on durations\n\n```scala\nval jacksonVersion = \"2.18.4\"\n\nlibraryDependencies ++= Seq(\n  \"com.fasterxml.jackson.datatype\" % \"jackson-datatype-jsr310\" % jacksonVersion,\n  \"com.fasterxml.jackson.module\" %% \"jackson-module-scala\" % jacksonVersion,\n  \"com.github.pjfanning\" %% \"jackson-module-scala-duration\" % jacksonVersion\n)\n```\n\n```scala\nimport com.fasterxml.jackson.databind.SerializationFeature\nimport com.fasterxml.jackson.datatype.jsr310.JavaTimeModule\nimport com.fasterxml.jackson.module.scala.DefaultScalaModule\nimport com.github.pjfanning.scala.duration.DurationModule\n\nval mapper = JsonMapper.builder()\n    .addModule(new JavaTimeModule)\n    .addModule(DefaultScalaModule)\n    .addModule(DurationModule)\n    .diasble(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)\n    .build()\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpjfanning%2Fjackson-module-scala-duration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpjfanning%2Fjackson-module-scala-duration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpjfanning%2Fjackson-module-scala-duration/lists"}