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: 6 days ago
JSON representation
Simple java library for displaying dates as relative time ago language.
- Host: GitHub
- URL: https://github.com/marlonlom/timeago
- Owner: marlonlom
- License: apache-2.0
- Created: 2016-11-19T04:49:25.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2025-03-31T08:40:11.000Z (15 days ago)
- Last Synced: 2025-04-02T01:53:22.918Z (13 days ago)
- Topics: android-library, dates, java-library, kotlin-library, time-and-date-diff, timeago
- Language: Kotlin
- Size: 2.02 MB
- Stars: 368
- Watchers: 4
- Forks: 74
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome - timeago - Simple java library for displaying dates as relative time ago language. (timeago)
- awesome - timeago - Simple java library for displaying dates as relative time ago language. (time-and-date-diff)
README
# TimeAgo
[](http://www.mvnrepository.com/artifact/com.github.marlonlom/timeago)
[](https://android-arsenal.com/details/1/4707)
[](https://github.com/marlonlom/timeago/actions/workflows/build.yml)
[](https://www.codefactor.io/repository/github/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 (Kotlin):
```
implementation("com.github.marlonlom:timeago:$latestVersion")
```Gradle (Groovy):
```
implementation "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), and more. You can see more
details [reading this information](docs/languages_supported.md).## Demo
Check the [Demo](https://goo.gl/y66vh4) here.

# Documentation
## Code-of-Conduct
See the [code of conduct](CODE_OF_CONDUCT.md) document for more information.
## Contributing
See the [Contributing](CONTRIBUTING.md) document for more information.
### License
This application is distributed under the terms of the Apache License (Version 2.0). See the [license](LICENSE) for more
information.```
Copyright 2016 marlonlomLicensed 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 athttp://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.
```