Skip to content

Instantly share code, notes, and snippets.

@sammy2077
Created March 18, 2020 20:06
Show Gist options
  • Save sammy2077/522982a71afec11bd47a6575d04c6328 to your computer and use it in GitHub Desktop.
Save sammy2077/522982a71afec11bd47a6575d04c6328 to your computer and use it in GitHub Desktop.
Getnerate current timestamp in kotlin
import java.time.Instant
import java.time.ZoneId
import java.time.format.DateTimeFormatter
fun main() {
val time=DateTimeFormatter
.ofPattern("yyyyMMddHHmmss")
.withZone(ZoneId.of("Africa/Nairobi"))
.format(Instant.now())
println(time)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment