You can't specifically have it interpret the value as minutes, but you can have it parsed as a Duration
. The string value is parsed to a long using this code:
private static long parseDelayAsLong(String value) throws RuntimeException {
if (value.length() > 1 && (isP(value.charAt(0)) || isP(value.charAt(1)))) {
return Duration.parse(value).toMillis();
}
return Long.parseLong(value);
}
If the value has a P
as its first or second character, it'll be turned into a long using Duration.parse(value)
. For example, a value of 5 minutes can be expressed as PT5M
.
You could configure your annotation to use ${jobinterval}
:
@Scheduled(fixedDelayString = "${jobinterval}")
You can then specify a numeric value in your yaml file that will be used as milliseconds:
jobinterval: 30000
Or you can specify a textural representation of a duration using whatever unit you want:
jobinterval: PT5M
jobinternal: PT300S