Quarkus - Prettytime

PrettyTime is an OpenSource time formatting library. It creates human readable, relative timestamps.


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:



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:

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

Native Support

This extension is fully supported in native mode.