当前位置: 首页 > 工具软件 > timeago > 使用案例 >

java显示时间的语句_显示时间前语句的简单java库 – timeago

连志义
2023-12-01

TimeAgo

显示时间前语句的简单java库。

Examples:

4 days ago

15 years ago

a minute ago

just now

Usage:

导入依赖:

Gradle:

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

Maven:

com.github.marlonlom

timeago

$latestVersion

默认使用方法:

/** using java.util.Date*/

TimeAgo.from(new java.util.Date().getTime());

/** using java.util.Calendar*/

TimeAgo.from(java.util.Calendar.getInstance().getTime().getTime());

With Specific Locale (by language tag):

语言支持: Spanish (es), English (en), German (de), French (fr), Italian (it), Portuguese (pt).

Locale LocaleBylanguageTag = Locale.forLanguageTag("es");

TimeAgoMessages messages = new TimeAgoMessages.Builder().withLocale(LocaleBylanguageTag).build();

TimeAgo.from(new java.util.Date().getTime(), messages);

 类似资料: