Add overloads to setExpiration and setIssuedAt
Aleksander-Dorkov opened this issue · 1 comments
Aleksander-Dorkov commented
Hello, do you have the time to add overloads to the methods setExpiration
and setIssuedAt
of Jwts.builder()
that accept LocalDateTime
instead of the Date class, witch was kind of deprecated (not rly, but almost) 10 years go.
Instant now = Instant.now();
JwtBuilder jwtBuilder = Jwts.builder()
.setId(UUID.randomUUID().toString())
.setSubject(userDetails.getId().toString())
.claim("username", userDetails.getUsername())
.claim("authorities", authorities)
.setIssuedAt(Date.from(now))
.setExpiration(Date.from(now.plus(1, ChronoUnit.DAYS)))
.signWith(KEY);
Instead of the code above can we have
JwtBuilder jwtBuilder = Jwts.builder()
.setId(UUID.randomUUID().toString())
.setSubject(userDetails.getId().toString())
.claim("username", userDetails.getUsername())
.claim("authorities", authorities)
.setIssuedAt(LocalDateTime.now())
.setExpiration(LocalDateTime.now().plus(1, ChronoUnit.DAYS))
.signWith(KEY);
It should be fairly simple, because you just convert them to a unix timestamp, if I am not mistaking.
lhazlewood commented
Closing as duplicate of #662