# Format

### Description

Formats numbers, time and timestamp.

Format on Vector will result in a comma-separated list of formatted values. \
E.g.: `Device Link Car, Fronius Symo`

Format on GroupedScalar will result in a  comma-separated list of group identifier, double-quote and formatted value; the group identifier is rendered as *device name*, if grouped by device, else the time span index is taken.\
E.g.: `'Device Link Car': 1035, 'Fronius Symo': 8012`

Format on GroupedVector will result in a  slash-separated list of group identifier, double-quote and comma-separated formatted values; the group identifier is rendered as *device name*, if grouped by device, else the time span index is taken.\
E.g.: `'Device Link Car': 1035, 2012, 3097 / 'Fronius Symo': 8012`

### Number/Event | Text

```java
Scalar<Number/Event> | Scalar<Text> → Scalar<Text>
Vector<Number/Event> | Scalar<Text> → Scalar<Text>
GroupedScalar<Number/Event> | Scalar<Text> → Scalar<Text>
GroupedVector<Number/Event> | Scalar<Text> → Scalar<Text>
```

Format pattern semantic, see [Java's DecimalFormat](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/text/DecimalFormat.html)

***

### Time | Text

```java
Scalar<Time> | Scalar<Text> →  Scalar<Text>
Vector<Time> | Scalar<Text> →  Scalar<Text>
GroupedScalar<Time> | Scalar<Text> →  Scalar<Text>
GroupedVector<Time> | Scalar<Text> →  Scalar<Text>
```

Format pattern semantic, see [Java's SimpleDateFormat](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/text/SimpleDateFormat.html)

***

### Timespan | Text

```java
Scalar<Time> | Scalar<Text> →  Scalar<Text>
Vector<Time> | Scalar<Text> →  Scalar<Text>
GroupedScalar<Time> | Scalar<Text> →  Scalar<Text>
GroupedVector<Time> | Scalar<Text> →  Scalar<Text>
```

Format pattern semantic, see [Java's SimpleDateFormat](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/text/SimpleDateFormat.html)

***

### Timespan | '(ADAPTIVE|SECONDS|MINUTES|HOURS|DAYS):(WORD|SYMBOL)'

```java
Scalar<Time> | '(ADAPTIVE|SECONDS|MINUTES|HOURS|DAYS):(WORD|SYMBOL)' →  Scalar<Text>
Vector<Time> | '(ADAPTIVE|SECONDS|MINUTES|HOURS|DAYS):(WORD|SYMBOL)' →  Scalar<Text>
GroupedScalar<Time> | '(ADAPTIVE|SECONDS|MINUTES|HOURS|DAYS):(WORD|SYMBOL)' →  Scalar<Text>
GroupedVector<Time> | '(ADAPTIVE|SECONDS|MINUTES|HOURS|DAYS):(WORD|SYMBOL)' →  Scalar<Text>
```

Format pattern semantic

<table><thead><tr><th width="249">Value</th><th>Description</th></tr></thead><tbody><tr><td>ADAPATIVE</td><td>Means that it chooses the time unit automatically depending on the value size</td></tr><tr><td>SECONDS</td><td>Redners the value in seconds.</td></tr><tr><td>MINUTES</td><td>Renders the value in minutes.</td></tr><tr><td>HOURS</td><td>Renders the value in hours.</td></tr><tr><td>DAYS</td><td>Renders the value days.</td></tr><tr><td>WORD</td><td>Is in the word form (e.g. Hours)</td></tr><tr><td>SYMBOL</td><td>Is in the abbreviation of the unit (e.g. h)</td></tr></tbody></table>

### Examples

Format the Result of the AVG($Consumption) function (which is a Scalar\<Number) in format '#,##0'.

<pre class="language-java"><code class="lang-java"><strong>AVG($Consumption) | '#.##0'
</strong></code></pre>

Format the Timestamp of the $Event (which is Scalar\<Event>) as hours and minutes.

```java
$Event::Timestamp | 'HH:mm'
```

Fromat the resulting Timestamp as Hours suffixed with the word Hours.

```java
(now - $Event::Timestamp) | 'HOURS:WORD'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.moost.io/platform-manual/rules/rule-language/operations/format.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
