/** * Return the value of the specified property as an {@link Instant} or {@code null} if * the value is not a valid {@link Long} representation of an epoch time. * @param key the key of the property * @return the property value */ public Instant getInstant(String key) { String s = get(key); if (s != null) { try { return Instant.ofEpochMilli(Long.parseLong(s)); } catch (NumberFormatException ex) { // Not valid epoch time } } return null; }
/** * Copy the specified key to the target {@link Properties} if it is set. * @param target the target properties to update * @param key the key */ protected void copyIfSet(Properties target, String key) { String value = this.properties.get(key); if (StringUtils.hasText(value)) { target.put(key, value); } }