Converting Interval to milliseconds (or some Unit of time)

#1

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,

0 Likes

#2

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

0 Likes

#3

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:

0 Likes