/** * Gets the specified claim (registered or custom) as * {@link java.util.Date}. The claim may be represented by a Date * object or a number of a seconds since the Unix epoch. * * @param name The name of the claim. Must not be {@code null}. * * @return The value of the claim, {@code null} if not specified. * * @throws ParseException If the claim value is not of the required * type. */ public Date getDateClaim(final String name) throws ParseException { Object value = getClaim(name); if (value == null) { return null; } else if (value instanceof Date) { return (Date)value; } else if (value instanceof Number) { return DateUtils.fromSecondsSinceEpoch(((Number)value).longValue()); } else { throw new ParseException("The \"" + name + "\" claim is not a Date", 0); } }
o.put(claim.getKey(), DateUtils.toSecondsSinceEpoch(dateValue));