Skip to content
master
Switch branches/tags
Go to file
Code
This branch is 6 commits behind heruan:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

Humanization libraries for Java

humanize total humanize humanize humanize

humanize-time

humanize time

Add the dependency to your pom.xml:

<dependency>
    <groupdId>to.lova.humanize</groupId>
    <artifactId>humanize-time</artifactId>
    <version>0.1.2</version>
</dependency>

Use it in your code as simple as:

Temporal minutesAgo = ZonedDateTime.now().minus(5, ChronoUnit.MINUTES);
String relative = HumanizeTime.fromNow(minutesAgo);
// produces: "5 minutes ago"

By default it uses the locale provided by Locale.getDefault(), but you can request a different one or provide your own resolver:

Temporal minutesAgo = ZonedDateTime.now().minus(5, ChronoUnit.MINUTES);
Locale.setDefault(Locale.ITALIAN);
String italian = HumanizeTime.fromNow(temporal);
// produces: "5 minuti fa"
String french = HumanizeTime.fromNow(temporal, Locale.FRENCH);
// produces: "il y a 5 minutes"
String japanese = HumanizeTime.fromNow(temporal, () -> Locale.JAPANESE);
// produces: "5時間前"

About

Humanization libraries for Java.

Resources

License

Packages

No packages published

Languages