public class DateUtils extends Object
| Constructor and Description |
|---|
DateUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
toDateAndTimeAgo(String isoFormattedDate) |
static String |
toTimeAgo(long epochMillis)
Thresholds are 60 seconds, 50 minutes, 20 hours, 3 weeks, 10 months.
Everything else is rounded (1.5 becomes 2). Surplus months except 1 are not rounded (1 year 2 months ago). 1 month are 30.42 days. |
static String |
toTimeAgo(String isoFormattedDate) |
public static String toDateAndTimeAgo(String isoFormattedDate)
isoFormattedDate - ISO timestamp "2021-12-31T23:59:59.123456789+18:00""2021-12-31T07:59:59+02:00 (1 year 2 months ago)"toTimeAgo(String)public static String toTimeAgo(String isoFormattedDate)
isoFormattedDate - ISO timestamp "2021-12-31T23:59:59.123456789+18:00""1 year 2 months ago"toTimeAgo(long)public static String toTimeAgo(long epochMillis)
Thresholds are 60 seconds, 50 minutes, 20 hours, 3 weeks, 10 months.
Everything else is rounded (1.5 becomes 2).
Surplus months except 1 are not rounded (1 year 2 months ago).
1 month are 30.42 days.
0 sec = a minute ago 89 sec = a minute ago 90 sec = 2 minutes ago 50 min = 50 minutes ago 51 min = an hour ago 89 min = an hour ago 90 min = 2 hours ago 20 hrs = 20 hours ago 21 hrs = yesterday 35 hrs = yesterday 36 hrs = 2 days ago 5 day = 5 days ago 6 day = a week ago 10 day = a week ago 11 day = 2 weeks ago 17 day = 2 weeks ago 18 day = 3 weeks ago 24 day = 3 weeks ago 25 day = a month ago 45 day = a month ago 46 day = 2 months ago 10 mon = 10 months ago 11 mon = a year ago 13 mon = a year ago 14 mon = 1 year 2 months ago 23 mon = 1 year 11 months ago 25 mon = 2 years ago 26 mon = 2 years 2 months ago
epochMillis - Unix time in milliseconds (since 1970-01-01)"1 year 2 months ago"Copyright © 2022. All rights reserved.