Last active
February 12, 2017 10:03
-
-
Save ilkinulas/26e651c8eee1c6bfa092f38a5858fc9e to your computer and use it in GitHub Desktop.
Sample for demonstrating extension functions in kotlin
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
package extensions | |
import java.text.SimpleDateFormat | |
import java.util.* | |
private val calendar: Calendar by lazy { | |
Calendar.getInstance() | |
} | |
fun Date.isSunday(): Boolean { | |
calendar.time = this | |
return calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY | |
} | |
fun main(args: Array<String>) { | |
val Subat_4_1979 = SimpleDateFormat("dd/MM/yyyy").parse("04/02/1979") | |
if (Subat_4_1979.isSunday()) { | |
println("Bir pazar gunu dogmusum.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment