Last active
October 18, 2021 21:58
-
-
Save Elschnagoo/8b981a3cab18cec200252126ccbc1d12 to your computer and use it in GitHub Desktop.
SemperVideo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2021-09-26 15:08:35,22.1.12.1,333389,connected | |
2021-09-26 15:10:35,22.1.12.1,333389,connected | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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