1616package io .jsonwebtoken ;
1717
1818import java .security .Key ;
19+ import java .time .Instant ;
1920import java .util .Date ;
2021import java .util .Map ;
2122
@@ -198,16 +199,16 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
198199 * <p>A JWT obtained after this timestamp should not be used.</p>
199200 *
200201 * <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
202+ * the Claims {@link Claims#setExpiration(java.time.Instant ) expiration} field with the specified value. This allows
202203 * you to write code like this:</p>
203204 *
204205 * <pre>
205- * String jwt = Jwts.builder().setExpiration(new Date (System.currentTimeMillis() + 3600000)).compact();
206+ * String jwt = Jwts.builder().setExpiration(Instant.ofEpochMilli (System.currentTimeMillis() + 3600000)).compact();
206207 * </pre>
207208 *
208209 * <p>instead of this:</p>
209210 * <pre>
210- * Claims claims = Jwts.claims().setExpiration(new Date (System.currentTimeMillis() + 3600000));
211+ * Claims claims = Jwts.claims().setExpiration(Instant.ofEpochMilli (System.currentTimeMillis() + 3600000));
211212 * String jwt = Jwts.builder().setClaims(claims).compact();
212213 * </pre>
213214 * <p>if desired.</p>
@@ -217,7 +218,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
217218 * @since 0.2
218219 */
219220 @ Override //only for better/targeted JavaDoc
220- JwtBuilder setExpiration (Date exp );
221+ JwtBuilder setExpiration (Instant exp );
221222
222223 /**
223224 * Sets the JWT Claims <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.5">
@@ -226,16 +227,16 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
226227 * <p>A JWT obtained before this timestamp should not be used.</p>
227228 *
228229 * <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
230+ * the Claims {@link Claims#setNotBefore(java.time.Instant ) notBefore} field with the specified value. This allows
230231 * you to write code like this:</p>
231232 *
232233 * <pre>
233- * String jwt = Jwts.builder().setNotBefore(new Date ()).compact();
234+ * String jwt = Jwts.builder().setNotBefore(Instant.now ()).compact();
234235 * </pre>
235236 *
236237 * <p>instead of this:</p>
237238 * <pre>
238- * Claims claims = Jwts.claims().setNotBefore(new Date ());
239+ * Claims claims = Jwts.claims().setNotBefore(Instant.now ());
239240 * String jwt = Jwts.builder().setClaims(claims).compact();
240241 * </pre>
241242 * <p>if desired.</p>
@@ -245,7 +246,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
245246 * @since 0.2
246247 */
247248 @ Override //only for better/targeted JavaDoc
248- JwtBuilder setNotBefore (Date nbf );
249+ JwtBuilder setNotBefore (Instant nbf );
249250
250251 /**
251252 * Sets the JWT Claims <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.6">
@@ -254,7 +255,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
254255 * <p>The value is the timestamp when the JWT was created.</p>
255256 *
256257 * <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
258+ * the Claims {@link Claims#setIssuedAt(java.time.Instant ) issuedAt} field with the specified value. This allows
258259 * you to write code like this:</p>
259260 *
260261 * <pre>
@@ -263,7 +264,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
263264 *
264265 * <p>instead of this:</p>
265266 * <pre>
266- * Claims claims = Jwts.claims().setIssuedAt(new Date ());
267+ * Claims claims = Jwts.claims().setIssuedAt(Instant.now ());
267268 * String jwt = Jwts.builder().setClaims(claims).compact();
268269 * </pre>
269270 * <p>if desired.</p>
@@ -273,7 +274,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
273274 * @since 0.2
274275 */
275276 @ Override //only for better/targeted JavaDoc
276- JwtBuilder setIssuedAt (Date iat );
277+ JwtBuilder setIssuedAt (Instant iat );
277278
278279 /**
279280 * 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