16
16
package io .jsonwebtoken ;
17
17
18
18
import java .security .Key ;
19
- import java .util . Date ;
19
+ import java .time . Instant ;
20
20
import java .util .Map ;
21
21
22
22
/**
@@ -198,16 +198,16 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
198
198
* <p>A JWT obtained after this timestamp should not be used.</p>
199
199
*
200
200
* <p>This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
201
- * the Claims {@link Claims#setExpiration(java.util.Date ) expiration} field with the specified value. This allows
201
+ * the Claims {@link Claims#setExpiration(java.time.Instant ) expiration} field with the specified value. This allows
202
202
* you to write code like this:</p>
203
203
*
204
204
* <pre>
205
- * String jwt = Jwts.builder().setExpiration(new Date (System.currentTimeMillis() + 3600000)).compact();
205
+ * String jwt = Jwts.builder().setExpiration(Instant.ofEpochMilli (System.currentTimeMillis() + 3600000)).compact();
206
206
* </pre>
207
207
*
208
208
* <p>instead of this:</p>
209
209
* <pre>
210
- * Claims claims = Jwts.claims().setExpiration(new Date (System.currentTimeMillis() + 3600000));
210
+ * Claims claims = Jwts.claims().setExpiration(Instant.ofEpochMilli (System.currentTimeMillis() + 3600000));
211
211
* String jwt = Jwts.builder().setClaims(claims).compact();
212
212
* </pre>
213
213
* <p>if desired.</p>
@@ -217,7 +217,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
217
217
* @since 0.2
218
218
*/
219
219
@ Override //only for better/targeted JavaDoc
220
- JwtBuilder setExpiration (Date exp );
220
+ JwtBuilder setExpiration (Instant exp );
221
221
222
222
/**
223
223
* Sets the JWT Claims <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.5">
@@ -226,16 +226,16 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
226
226
* <p>A JWT obtained before this timestamp should not be used.</p>
227
227
*
228
228
* <p>This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
229
- * the Claims {@link Claims#setNotBefore(java.util.Date ) notBefore} field with the specified value. This allows
229
+ * the Claims {@link Claims#setNotBefore(java.time.Instant ) notBefore} field with the specified value. This allows
230
230
* you to write code like this:</p>
231
231
*
232
232
* <pre>
233
- * String jwt = Jwts.builder().setNotBefore(new Date ()).compact();
233
+ * String jwt = Jwts.builder().setNotBefore(Instant.now ()).compact();
234
234
* </pre>
235
235
*
236
236
* <p>instead of this:</p>
237
237
* <pre>
238
- * Claims claims = Jwts.claims().setNotBefore(new Date ());
238
+ * Claims claims = Jwts.claims().setNotBefore(Instant.now ());
239
239
* String jwt = Jwts.builder().setClaims(claims).compact();
240
240
* </pre>
241
241
* <p>if desired.</p>
@@ -245,7 +245,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
245
245
* @since 0.2
246
246
*/
247
247
@ Override //only for better/targeted JavaDoc
248
- JwtBuilder setNotBefore (Date nbf );
248
+ JwtBuilder setNotBefore (Instant nbf );
249
249
250
250
/**
251
251
* Sets the JWT Claims <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.6">
@@ -254,7 +254,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
254
254
* <p>The value is the timestamp when the JWT was created.</p>
255
255
*
256
256
* <p>This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
257
- * the Claims {@link Claims#setIssuedAt(java.util.Date ) issuedAt} field with the specified value. This allows
257
+ * the Claims {@link Claims#setIssuedAt(java.time.Instant ) issuedAt} field with the specified value. This allows
258
258
* you to write code like this:</p>
259
259
*
260
260
* <pre>
@@ -263,7 +263,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
263
263
*
264
264
* <p>instead of this:</p>
265
265
* <pre>
266
- * Claims claims = Jwts.claims().setIssuedAt(new Date ());
266
+ * Claims claims = Jwts.claims().setIssuedAt(Instant.now ());
267
267
* String jwt = Jwts.builder().setClaims(claims).compact();
268
268
* </pre>
269
269
* <p>if desired.</p>
@@ -273,7 +273,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
273
273
* @since 0.2
274
274
*/
275
275
@ Override //only for better/targeted JavaDoc
276
- JwtBuilder setIssuedAt (Date iat );
276
+ JwtBuilder setIssuedAt (Instant iat );
277
277
278
278
/**
279
279
* Sets the JWT Claims <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.7">
0 commit comments