Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marlonlom/timeago

Simple java library for displaying dates as relative time ago language.
https://github.com/marlonlom/timeago

android-library dates java-library kotlin-library time-and-date-diff timeago

Last synced: about 1 month ago
JSON representation

Simple java library for displaying dates as relative time ago language.

Awesome Lists containing this project

README

        

# TimeAgo

[![Maven Central](https://img.shields.io/maven-central/v/com.github.marlonlom/timeago.svg)](http://www.mvnrepository.com/artifact/com.github.marlonlom/timeago)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Timeago-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/4707)
[![Download](https://api.bintray.com/packages/marlonlom/timeago/timeago/images/download.svg) ](https://bintray.com/marlonlom/timeago/timeago/_latestVersion)
[![Build Status](https://travis-ci.org/marlonlom/timeago.svg?branch=master)](https://travis-ci.org/marlonlom/timeago)

Simple java library for displaying dates as relative time ago language.

## Examples:
- 4 days ago
- 15 years ago
- a minute ago
- just now

## Usage:

### Import as a dependency:

Gradle:

```
compile 'com.github.marlonlom:timeago:$latestVersion'
```

Maven:

```xml

com.github.marlonlom
timeago
$latestVersion

```

### Use it in your code:

```java
String text = TimeAgo.using(timeInMillis);
```

Where _timeInMillis_, based on current date and time, is defined like

```java
/* You can use java.util.Calendar.getInstance().getTimeInMillis()*/
/* Also, with java 8, java.time.Instant.now().toEpochMilli() */

long timeInMillis = System.currentTimeMillis();
```

### With Specific Locale (by language tag):

For specific language usage, use _TimeAgoMessages_:

```java
Locale LocaleBylanguageTag = Locale.forLanguageTag("es");
TimeAgoMessages messages = new TimeAgoMessages.Builder().withLocale(LocaleBylanguageTag).build();

String text = TimeAgo.using(timeInMillis, messages);
```

Languages supported: Spanish (es), English (en), Dutch (nl), German (de), French (fr), Italian (it), Portuguese (pt), Indonesian (id), Czech (cs), Arabic (ar).

## Demo

Check the [Demo](https://goo.gl/y66vh4) here.

## Spread the word

If you like this library, please tell others about it :thumbsup::thumbsup:



- []()Follow me on **Twitter**: [**@Marlonlom**](https://twitter.com/marlonlom)
- Contact me on **LinkedIn**: [**Marlonlom**](https://co.linkedin.com/in/marlonlom)

### License

```
Copyright 2016 marlonlom

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```