Example usage for java.sql Date toInstant

List of usage examples for java.sql Date toInstant

Introduction

In this page you can find the example usage for java.sql Date toInstant.

Prototype

@Override
public Instant toInstant() 

Source Link

Document

This method always throws an UnsupportedOperationException and should not be used because SQL Date values do not have a time component.

Usage

From source file:io.cfp.auth.service.TokenService.java

/**
  * Check if token is valid/*from   www  . j a  v a  2s  .co  m*/
  * @param token
  * @return
  */
public boolean isValid(String token) {
    try {
        java.util.Date expiration = Jwts.parser().setSigningKey(signingKey).parseClaimsJws(token).getBody()
                .getExpiration();
        if (expiration == null)
            return false;

        return expiration.toInstant().isAfter(Instant.now());
    } catch (ExpiredJwtException | UnsupportedJwtException | SignatureException | MalformedJwtException
            | IllegalArgumentException e) {
        return false;
    }
}