mirror of
https://github.com/jwtk/jjwt.git
synced 2025-03-09 06:46:50 +00:00
122: added code comments so readers understand that JWT mandates seconds, not milliseconds
This commit is contained in:
parent
5b15b9363e
commit
af01cca922
@ -47,10 +47,16 @@ public class JwtMap implements Map<String,Object> {
|
||||
} else if (v instanceof Date) {
|
||||
return (Date) v;
|
||||
} else if (v instanceof Number) {
|
||||
// https://github.com/jwtk/jjwt/issues/122:
|
||||
// The JWT RFC *mandates* NumericDate values are represented as seconds.
|
||||
// Because Because java.util.Date requires milliseconds, we need to multiply by 1000:
|
||||
long seconds = ((Number) v).longValue();
|
||||
long millis = seconds * 1000;
|
||||
return new Date(millis);
|
||||
} else if (v instanceof String) {
|
||||
// https://github.com/jwtk/jjwt/issues/122
|
||||
// The JWT RFC *mandates* NumericDate values are represented as seconds.
|
||||
// Because Because java.util.Date requires milliseconds, we need to multiply by 1000:
|
||||
long seconds = Long.parseLong((String) v);
|
||||
long millis = seconds * 1000;
|
||||
return new Date(millis);
|
||||
|
Loading…
x
Reference in New Issue
Block a user