question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Java8 Date/Time formats

See original GitHub issue

Hi, Maybe I’m missing something so apologies if this is not an issue. I’ve configured my spring boot application to use jackson-datatype-jsr310 by including in pom.xml, all outgoing json is serialized correctly. however I am using a hashmap to set the payload of the the jwt token:

hashMap.put(Claims.ISSUED_AT,LocalDateTime.now);

and this is being serialized in the Long LocalDateTimeFormat:

{"hour":9,"minute":53,"second":49,"nano":288000000,"dayOfYear":193,"dayOfWeek":"WEDNESDAY","month":"JULY","dayOfMonth":12,"year":2017,"monthValue":7,"chronology":{"calendarType":"iso8601","id":"ISO"}

I had a similar issue in another spring boot application where I was using new ObjectMapper() and not using springBoots configured ObjectMapper. Any ideas how I could make jjwt pick up springboots ObjectMapper which would be configured correctly ? I’m using using jjwt version 0.7.0.

Thanks in advance for your help, Peter

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
marschallcommented, Jan 5, 2020

I would not support LocalDateTime. LocalDateTime is not an instant and therefore does not identify a point in time. You would need a time zone for that. Which means you don’t know how much time has passed since a claim was issued which means that you don’t know whether it is expired.

Even the JSR-310 expert group leader thinks LocalDateTime is not generally useful. https://github.com/tc39/proposal-temporal/issues/7#issuecomment-288997620

4reactions
marschallcommented, Jan 5, 2020

@RockyMM sure, Instant, OffsetDateTime and ZonedDateTime are a great addition and completely fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction to the Java 8 Date/Time API - Baeldung
The LocalDate represents a date in ISO format (yyyy-MM-dd) without time. We can use it to store dates like birthdays and paydays. An...
Read more >
DateTimeFormatter (Java Platform SE 8 ) - Oracle Help Center
Formatter for printing and parsing date-time objects. This class provides the main application entry point for printing and parsing and provides common ...
Read more >
How to Format Date to String in Java 8 [Example Tutorial]
How to change the format of Date in Java String using JDK 8 ; "yyyy-MM-dd HH:mm:ss"); DateTimeFormatter newPattern = ; "yyyy-MM-dd"); LocalDateTime datetime...
Read more >
How to Format Date and Time in the Java 8 Date/Time API
Open your text editor and create the Java program that will demonstrate formatting date and time. · Save your file as FormattingDateAndTime. ·...
Read more >
Java DateTimeFormatter with Examples - HowToDoInJava
Learn to use DateTimeFormatter for formatting ZonedDateTime , LocalDateTime , LocalDate and LocalTime to string with predefined and custom ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found