Skip to content

quarkiverse/quarkus-prettytime

Repository files navigation

Quarkus - Pretty Time

All Contributors

Social Style Date and Time Formatting for Java

Version

PrettyTime is an OpenSource time formatting library. Completely customizable, it creates human readable, relative timestamps. This extension allows you to use this library in Quarkus native applications.

You can find more about it at https://www.ocpsoft.org/prettytime/.

To get started, add the dependency:

<dependency>
    <groupId>io.quarkiverse.prettytime</groupId>
    <artifactId>quarkus-prettytime</artifactId>
    <version>999-SNAPSHOT</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.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


George Gastaldi

💻 🚧

Martin Kouba

💻

This project follows the all-contributors specification. Contributions of any kind welcome!