Skip to content

Instantly share code, notes, and snippets.

Avatar
🤒
Out sick

arjava arjava

🤒
Out sick
View GitHub Profile
@arjava
arjava / convert UTC to GMT time in Kotlin
Last active Apr 22, 2018
snippet code for convert UTC to GMT using Kotlin
View convert UTC to GMT time in Kotlin
override fun convertToGmt() {
val sdfTime = SimpleDateFormat("HH:mm:ss")
sdfTime.timeZone = TimeZone.getTimeZone("UTC")
val dateTime = scheduleMatch.timeMatch
val gmtTime = sdfTime.parse(dateTime).toString()
println(gmtTime)
}
@arjava
arjava / back-handling-kotlin
Created Mar 27, 2018
Handling back button in kotlin
View back-handling-kotlin
override fun onOptionsItemSelected(item: MenuItem?) = when (item?.itemId) {
android.R.id.home -> consume { finish() }
else -> super.onOptionsItemSelected(item)
}
private inline fun consume(f: () -> Unit): Boolean {
f()
return true
}