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 convert milli seconds to hours, minutes and seconds in Android?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
Hide/Disable soft keyboard on Activity launch: Android
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How to get screen size (width,height) in Android?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
Check List for Generate Signed APK Android
How to validate email address in Android with Kotlin?
What are the notifications available in android?
How to check Android version?
Invoke-customs are only supported starting with android 0 --min-api 26
How to install/ uninstall apk by command line ADB
How to get complete address from latitude and longitude?
What are Android Versions available?
What is the Different Between val and var in Kotlin?
What is "shared preferences" in Android ?
How to Get bitmap from drawable: Android
How to Exit android app on back pressed?
What is Android?
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
How to Use Deprecated Handler() in Android - RRutors Guide
How to convert DP to Pixel and Pixel to Dp?
What is ANR? How to avoid and resolve it?
What is Android Fragments?
Android Studio project R can't find
How do I generate random numbers in Dart?
How do i load image from drawable folder in Jetpack Compose?
Extract Date and Time from Long Type Variable - RRutors
How to save activity State in Android?
How do I check in SQLite whether a table exists?
How to Generate signed apk with android studio
What is Intent? What is the difference between an implicit intent and an explicit intent?
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to get a contact image using a phone number in android?
Key Points to remember while develop the Android Application.
How to stop EditText focus at Activity startup in Android?
What is Application?
What happens next when the device switches between portrait and landscape?
What is the difference between match_parent and fill_parent?
How can i comment inside xml file in android studio?