With Below code we can get date and time import java.text.SimpleDateFormat fun convertLongToTime (time: Long): String { From API level 26 on (Android) or if JVM is your target, we can use Java 8 Date API: val date = Instant val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm") Below API level 26: val date = Date(1595386325905) val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm")
import java.util.Date
val date = Date(time)
val format = SimpleDateFormat("dd/M/yyyy hh:mm:ss")
return format.format(date)
}
.ofEpochMilli(1164925597950)
.atZone(ZoneId.systemDefault()) // change time zone if necessary
.toLocalDateTime()
println(formatter.format(date))
println(formatter.format(date))
How to stop EditText focus at Activity startup in Android?
Hide/Disable soft keyboard on Activity launch: Android
How to save activity State in Android?
Add Jar/Library Files as Dependency in Android Studio
What is the Different Between val and var in Kotlin?
How to avoid multiple button click at same time in android?
Permission denied for window type 2010 in Marshmallow device
How to reduce APK package size?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
What are Android Versions available?
How to find Android Device UDID or unique ID?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
What are the notifications available in android?
How to copy database from assets folder in android using kotlin
Symmetric vs Asymmetric Encryption in Android Server - RRutors
What is Application?
What is NetworkOnMainThread Exception?
How to check Android version?
What is ANR? How to avoid and resolve it?
Explain Fragment Life Cycle
Check List for Generate Signed APK Android
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to Use Deprecated Handler() in Android - RRutors Guide
What is Android?
Set Activity to Fullscreen Mode in Android - RRutors
What is Intent? What is the difference between an implicit intent and an explicit intent?
Extract Date and Time from Long Type Variable - RRutors
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
What is Context?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
Decompile APK Files: How to Get Source Code - RRutors Guide
Key Points to remember while develop the Android Application.
Fix Play Store Rejection Due to SMS Permission - RRutors
How do i load image from drawable folder in Jetpack Compose?
What is "shared preferences" in Android ?
How to convert milli seconds to hours, minutes and seconds in Android?
FCM Not Receiving Notifications in Android - RRutors
What happens next when the device switches between portrait and landscape?
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
How to start a new activity on button click