Converting Interval to milliseconds (or some Unit of time)


I am interested in converting an Interval (“TEN_MINUTE”, “HALF_HOUR”, “DAY”, etc.) to a corresponding number of milliseconds.

I imagine there is a Type that has such a method since we probably do some mapping of these intervals to step size in the metric engine. Can someone please point me to it?

If it’s not available to me, I can create my own mapping, but I was thinking this might already exist.

Thank you,



You could use Period.fromString('1d').toDuration().milliseconds()



Thanks Rohit, Sounds like I need to build a mapping between the “DAY” interval and the ‘1d’ Period?

Is there a way to avoid any mapping and go straight from Interval to milliseconds?

Also, copying and pasting Period.fromString('1d').toDuration().milliseconds() into static console produced an error: