Last active
January 23, 2021 16:30
-
-
Save tomergoldst/7474db6b10278016dc1464d20791cee9 to your computer and use it in GitHub Desktop.
This file contains 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 getDaysBetweenRoundUp(t1: Long, t2: Long): Int { | |
val msDiff = t2 - t1 | |
val daysFraction = msDiff.toFloat() / android.text.format.DateUtils.DAY_IN_MILLIS | |
return ceil(daysFraction.toDouble()).toInt() | |
} | |
fun getDaysBetweenRoundUp(c1: Calendar, c2: Calendar): Int { | |
return getDaysBetweenRoundUp(c1.timeInMillis, c2.timeInMillis) | |
} | |
fun getDaysBetween(t1: Long, t2: Long): Int { | |
val msDiff = t2 - t1 | |
return TimeUnit.MILLISECONDS.toDays(msDiff).toInt() | |
} | |
fun getDaysBetween(c1: Calendar, c2: Calendar): Int { | |
return getDaysBetween(c1.timeInMillis, c2.timeInMillis) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment