Package org.javalite.common
Class HumanDate
java.lang.Object
org.javalite.common.HumanDate
This is a helper class for converting distance bewteen two dates to a human format, like:
"two days", "three months", etc.
It was inspired by a Rails helper method:
distance_of_time_in_words
- Author:
- Igor Polevoy
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringtoHumanFormat(long fromTime)This is a convenience method in addition totoHumanFormat(long, long), except the second parameter is always now.static StringtoHumanFormat(long fromTime, long toTime)Generates a human representation of distance in time between two time stamps.
-
Method Details
-
toHumanFormat
Generates a human representation of distance in time between two time stamps. This could take a form: "less than a minute", or "about a year".- Parameters:
fromTime- start timestamp. This is a representation of time in milliseconds from January 1 1970.toTime- end timestamp. This is a representation of time in milliseconds from January 1 1970.- Returns:
- human representation if distance in time between
fromTimeandtoTime.
-
toHumanFormat
This is a convenience method in addition totoHumanFormat(long, long), except the second parameter is always now.- Parameters:
fromTime- start date. This is a representation of time in milliseconds from January 1 1970.- Returns:
- human imprecise representation of time difference between the
fromTimeand now.
-