Created
October 20, 2020 06:45
-
-
Save Tamkien/51ddc3309b69ca637590d38a8227f989 to your computer and use it in GitHub Desktop.
A function to add a field (Calendar.SOMETHING) into a given date. To minus, put a negative number.
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
private fun Date.add(field: Int, amount: Int): Date = Calendar.getInstance().let { calendar -> | |
calendar.time = this@add | |
calendar.add(field, amount) | |
return@let calendar.time | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment