I'm working on a program where I search through two text files and compare them (It's a task from JetBrains Academy). At the end I'm tasked to output the time it took to execute this, in the format of "mm:ss:ms". Picture as reference:
This is the code I've written to try to achieve this. I imagine it's pretty far from correct, so I apologize for this, I have been learning Kotlin and programming for not long.
val millis = System.currentTimeMillis()
val time = String.format("%1\$tM min. %1\$tS sec. %1\$tL ms.", millis);
println("Start searching...")
println("Found $number. Time taken: $time ")
The output I get is this:
> Start searching...
Found 864 / 864. Time taken: 19 min. 53 sec. 611 ms.
The minutes and seconds are wrong, as it took less than a second. I have doubts about the ms, as they would fit on how much time it took. Can someone help me with what I'm doing wrong? Thanks!