#Difference Between TwoTime Date Format in android studio kotlin
Explore tagged Tumblr posts
jeeteshsurana · 5 years ago
Link
Difference Between TwoTime in android studio kotlin 
fun getServerDates(Dates: String?): Date {
        val inputFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH)
        return inputFormat.parse(Dates)
}
private fun getSameDateFormat(): Date {
        val dateFormatGmt = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH)
        dateFormatGmt.timeZone = TimeZone.getTimeZone("GMT")
        val dateFormatLocal = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH)
        return dateFormatLocal.parse(dateFormatGmt.format(Date()))
}
private fun printDifference(startDate: Date, endDate: Date): String {
        //milliseconds
        var different = endDate.time - startDate.time
        val secondsInMilli: Long = 1000
        val minutesInMilli = secondsInMilli * 60
        val hoursInMilli = minutesInMilli * 60
        val daysInMilli = hoursInMilli * 24
        val elapsedDays = different / daysInMilli
        different %= daysInMilli
        val elapsedHours = different / hoursInMilli
        different %= hoursInMilli
        val elapsedMinutes = different / minutesInMilli
        different %= minutesInMilli
        val elapsedSeconds = different / secondsInMilli
        return if (elapsedDays != 0L) {
            "$elapsedDays${"d"}${" "}$elapsedHours${":"}$elapsedMinutes${":"}$elapsedSeconds"
        } else {
            "$elapsedHours${":"}$elapsedMinutes${":"}$elapsedSeconds"
        }
}
//access method 
val result =printDifference(getSameDateFormat(), getServerDates(data!!))
0 notes
jeeteshsurana · 5 years ago
Text
Difference Between TwoTime Date Format in android studio kotlin
https://ift.tt/39II45K
Difference Between TwoTime in android studio kotlin 
fun getServerDates(Dates: String?): Date {
        val inputFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH)
        return inputFormat.parse(Dates)
}
private fun getSameDateFormat(): Date {
        val dateFormatGmt = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH)
        dateFormatGmt.timeZone = TimeZone.getTimeZone("GMT")
        val dateFormatLocal = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH)
        return dateFormatLocal.parse(dateFormatGmt.format(Date()))
}
private fun printDifference(startDate: Date, endDate: Date): String {
        //milliseconds
        var different = endDate.time - startDate.time
        val secondsInMilli: Long = 1000
        val minutesInMilli = secondsInMilli * 60
        val hoursInMilli = minutesInMilli * 60
        val daysInMilli = hoursInMilli * 24
        val elapsedDays = different / daysInMilli
        different %= daysInMilli
        val elapsedHours = different / hoursInMilli
        different %= hoursInMilli
        val elapsedMinutes = different / minutesInMilli
        different %= minutesInMilli
        val elapsedSeconds = different / secondsInMilli
        return if (elapsedDays != 0L) {
            "$elapsedDays${"d"}${" "}$elapsedHours${":"}$elapsedMinutes${":"}$elapsedSeconds"
        } else {
            "$elapsedHours${":"}$elapsedMinutes${":"}$elapsedSeconds"
        }
}
//access method 
val result =printDifference(getSameDateFormat(), getServerDates(data!!))
via Blogger https://ift.tt/2WfesJt
0 notes