> For the complete documentation index, see [llms.txt](https://doc.moost.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.moost.io/platform-manual/rules/rule-language/operations/format.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
