Skip to content

Instantly share code, notes, and snippets.

@ilkinulas
Last active February 12, 2017 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilkinulas/26e651c8eee1c6bfa092f38a5858fc9e to your computer and use it in GitHub Desktop.
Save ilkinulas/26e651c8eee1c6bfa092f38a5858fc9e to your computer and use it in GitHub Desktop.
Sample for demonstrating extension functions in kotlin
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