public interface IRelativeDate extends java.lang.Comparable<IRelativeDate>
toString()
is properly overridden to produce the relative date as a human readable string (in English).
Instances are "table-friendly": you can use instances in tables and they can be sorted properly.
Modifier and Type | Method and Description |
---|---|
long |
getDeltaMs()
Returns the absolute value of the represented relative time to the creation time, in milliseconds.
|
int |
getTokens()
Returns the default value of tokens used by
toString() . |
boolean |
isAppendEra()
Returns the default value of append era used by
toString() . |
boolean |
isFuture()
Tells if the represented absolute time is in the future.
Note: if the represented absolute date is equal to the creation date, this will be false . |
boolean |
isLongForm()
Returns the default value of long form used by
toString() . |
java.lang.String |
toString()
Returns a human readable English string representation of this relative date using the default configuration returned by the
isLongForm() ,
getTokens() and isAppendEra() methods. |
java.lang.String |
toString(boolean longForm,
int tokens,
boolean appendEra)
Returns a human readable English string representation of this relative date.
|
long getDeltaMs()
boolean isFuture()
false
.boolean isLongForm()
toString()
.toString()
int getTokens()
toString()
.toString()
boolean isAppendEra()
toString()
.toString()
java.lang.String toString()
isLongForm()
,
getTokens()
and isAppendEra()
methods.toString
in class java.lang.Object
toString(boolean, int, boolean)
java.lang.String toString(boolean longForm, int tokens, boolean appendEra)
The longForm
parameter specifies if a long format is to be used, with whole words, else only letters.
Unit long format: | sec | min | hour(s) | day(s) | week(s) | month(s) | year(s) |
---|---|---|---|---|---|---|---|
Unit short format: | s | m | h | d | w | M | y |
The tokens
parameter specifies how many tokens to include in the output.
Example outputs in case the relative date is 94903000 ms
in the past:
Tokens: | 1 | 2 | 3 | ≥4 |
---|---|---|---|---|
Long format: | 1 day ago | 1 day and 2 hours ago | 1 day, 2 hours and 21 min ago | 1 day, 2 hours, 21 min and 43 sec ago |
Short format: | 1d ago | 1d 2h ago | 1d 2h 21m ago | 1d 2h 21m 43s ago |
longForm
- tells if long form is to be used for time unitstokens
- tells how many tokens to includeappendEra
- tells if era is to be appended; era is "ago"
for past times and "from now"
for future times
This API documentation is public and is intended for / allowed to be used by anyone.
Scelight home page: https://sites.google.com/site/scelight/
Scelight is a trademark of András Belicza. Copyright © András Belicza, 2013-2015. All rights reserved.