Created
May 8, 2019 17:55
-
-
Save EmmanuelGuther/73d7b1fd777b0f7290a6bf2d30a79aee to your computer and use it in GitHub Desktop.
Extension function to check if timestamp value is before X days
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Long.checkTimeIsOldThan(days: Int): Boolean { | |
val daysInMillis = TimeUnit.DAYS.toMillis(days.toLong()) | |
val currentTime = Date().time | |
val previousTime = this | |
val differ = currentTime - previousTime | |
return !(differ < daysInMillis && differ > -daysInMillis) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment