Skip to content

To Time (ms)#

The To Time (ms) converter receives a human-readable time expression as a String (for example, "2s", "1.5h", "2 days") and transforms it into the equivalent number of milliseconds as a Long. If the input is already a Number, the converter passes it through unchanged. Invalid or unrecognized expressions cause the converter to fail.

This is useful to feed time-based inputs (timeouts, delays, intervals) in a readable way while still passing a numeric value to the consuming task.

Settings#

This converter has no settings.

To Time Converter Settings

Examples#

String input#

Human-readable time expressions are parsed into their millisecond equivalent.

Input Output (ms)
500ms 500
2s 2000
2 seconds 2000
1m 60000
1 minute 60000
1.5h 5400000
2d 172800000
1w 604800000
123456780 123456780

Table 1: String Input Examples

Number input#

The converter treats numeric inputs as already in milliseconds and returns them unchanged.

Input Output (ms)
3000 3000
0 0

Table 2: Number Input Examples

Invalid Input#

This converter fails in any of the cases below. For what happens to the rest of the chain when a converter fails (the error is logged, reported for monitoring, and the next task does not run), see Converters.

Input Result
not-a-time Fails with invalid result for time expression "not-a-time"
(empty) Fails with invalid time expression "".

Table 3: Invalid Input