jtimeago
![Quality Gate Status](https://camo.githubusercontent.com/c558e018863d261c735e5981549ffa43687a796c81246c46b9b7901caee94be1/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636f6d2e61657273652533416a74696d6561676f266d65747269633d616c6572745f737461747573)
Tag lib for various date formatting:
- "Time ago". Examples: 1 seconds ago, 2 months ago, just now
- Interval. Examples: 2 months, 5 years, 1 year
Usage
Include dependency:
<dependency>
<groupId>com.aerse</groupId>
<artifactId>jtimeago</artifactId>
<version>1.3</version>
</dependency>
Configure taglib:
<%@ taglib prefix="ta" uri="https://github.com/dernasherbrezon/jtimeago" %>
Time ago
Use as normal JSTL formatDate:
<ta:formatDate value="${comment.date}" pattern="dd MMM yyyy HH:mm" />
Supported configuration parameters:
- value. Required. java.util.Date to format
- pattern. Required. Pattern for SimpleDateFormat. Used for more than one day ago dates.
- timeZone. Optional. String or java.util.TimeZone
- var. Optional. Output into var with defined scope.
- scope. Optional. scope for var
Interval
Format "years":
<ta:formatYear value="10" />
Supported configuration parameters:
- value. Required. Number.
- var. Optional. Output into var with defined scope.
- scope. Optional. scope for var
Format "months":
<ta:formatMonth value="10" />
Supported configuration parameters:
- value. Required. Number.
- var. Optional. Output into var with defined scope.
- scope. Optional. scope for var