Skip to content

Instantly share code, notes, and snippets.

@Elschnagoo
Last active October 18, 2021 21:58
Show Gist options
  • Save Elschnagoo/8b981a3cab18cec200252126ccbc1d12 to your computer and use it in GitHub Desktop.
Save Elschnagoo/8b981a3cab18cec200252126ccbc1d12 to your computer and use it in GitHub Desktop.
SemperVideo
2021-09-26 15:08:35,22.1.12.1,333389,connected
2021-09-26 15:10:35,22.1.12.1,333389,connected
import java.io.File
import java.time.Duration
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
fun readFileAsLinesUsingBufferedReader(fileName: String): List<String>
= File(fileName).bufferedReader().readLines()
fun main(args: Array<String>) {
val path="" //PATH
val lines = readFileAsLinesUsingBufferedReader(path)
val first =lines.get(0);
val second =lines.get(1);
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
val onlyDateFirst=first.split(",")[0];
val onlyDateSecond=second.split(",")[0];
val st = LocalDateTime.parse(onlyDateFirst, formatter);
val et = LocalDateTime.parse(onlyDateSecond, formatter);
val diff: Duration = Duration.between(st, et)
println( diff.toMinutes())
println( diff.toHours())
println( diff.toDays())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment