Quarkus - Prettytime

Describe what the extension does here.

Installation

If you want to use this extension, you need to add the io.quarkiverse.prettytime:quarkus-prettytime extension first. In your pom.xml file, add:

<dependency>
    <groupId>io.quarkiverse.prettytime</groupId>
    <artifactId>quarkus-prettytime</artifactId>
    <version>1.0.0</version>
</dependency>

Features

Inject PrettyTime Singleton

A singleton org.ocpsoft.prettytime.PrettyTime can be injected anywhere.

// Inject PrettyTime using the default locale
@Inject PrettyTime prettyTime;

Important: Be aware that any changes to the injected PrettyTime object (as in calling setLocale or setReference) will reflect on the singleton and its usage in your entire application. In cases where you need to format to a specific locale we recommend you to create a new PrettyTime object instead.

The singleton may be referenced by the name prettyTime when used in a non-typesafe environment such as templates. For example, if used together with the Qute templating engine:

<table>
  {#for label in labels}
  <tr>
    <td>{label.name}</td>
    <td>Created {inject:prettyTime.format(label.created)}</td>
  </tr>
  {/for}
</table>

Native Support

This extension is fully supported in native mode.