$millis:

   The $millis: function shortcut converts a human-friendly duration string specifier into the actual millisecs value represented. You can use this shortcut to make your scripts more readable and maintainable. The $millis: funcut is a query only feature– you cannot use it to modify existing data.

The $millis: funcut is advanced funcut that is not automatically installed by the standard AntXtras funcuts antlib. You must explicitly install this funcut’s handler; read the Examples section to see how this is done.

Parameters

The general form of the function shortcut is: $millis:<specifier> where <specifier> is the encoded duration string to be translated to a number value. The duration string is a set of plus (+) delimited time unit lengths; the available units are:

  • m[in] - minutes
  • s[ec] - seconds
  • S or ms[ec] - milliseconds
  • h[r] - hours
  • d[y] - days

Each time unit is preceded by its duration value; for example: “30min” or “4h”. The final milliseconds value is derived from the sum of all the time units converted to their millisecond equivalents; so “2h+30m” would be converted to “9000000”. The funcut also allows plurals of the time units so “5sec” is the same as “5secs”.

Examples

Installing $millis: shortcut

The following snippet explicitly installs the millis function shortcut and links it to the ‘$millis:’ scheme. If you choose to activate shortcuts manually, you’ll need to do something like this at the start of your Ant script’s execution.

1: <oja:managefuncuts action="enable">
2:   <parameter name="millis"
3:     value="${ojaf}.datetime.MillisecsFunctionShortcut"/>
4: </oja:managefuncuts>
Using to setup parameter default values

The following snippet uses the $millis funcut to setup a set of default millisecond values for both a macrodef attribute as well as global property (which the antlib macrodef does not assume exists).

 1: [in antlib...]
 2: <macrodef name="pingwlserver">
 3:   <attribute name="maxwait" default="${$p:MAXWAIT?${$millis:5mins}}"/>
 4: 5: </macrodef>
 6: 7: [in script...]
 8: <fallback name="MAXWAIT" value="${$millis:2min+30sec}"/>
 9:

Related Topics


Navigation
Personal Tools