Search code examples
kotlinjacksonjavalin

Format LocalDateTime Response json


I would like to format my LocalDateTime on Javalin.

I know the library uses Jackson to generate JSON and I also know how to configure it but where can I set the Jackson configuration?

I would like to format my dates in this format, "dd-MM-yyyy hh:mm:ss".

Thank you


Solution

  • In Javalin, Jackson is configurable via JavalinJackson#configure ().

    In my specific case, I would do

    JavalinJackson.configure(jacksonObjectMapper().findAndRegisterModules())
    

    and then add the appropriate dependency:

    compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8"