This article explores different ways to get current time without date in Kotlin.

1. Using java.util.LocalTime class

The java.time package contains the LocalTime class that represents a time without a time-zone. We can use it as follows:

Download Code

Output (will vary):

10:30:21.039935600

 
To get the time-zone specific time, pass that zone’s ID to the LocalTime.now() function.

Download Code

Output (will vary):

05:30:21.039935600

2. Using java.util.Date class

An alternative idea is to create a new java.util.Date instance using its no-arg constructor, which initializes it with the current date & time. To only filter time in the specific format, use the SimpleDateFormat class.

Download Code

Output (will vary):

06:25:59 pm

That’s all about getting current time without date in Kotlin.