 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert TimeStamp to DateTime in Kotlin?\\n
Kotlin is a statistically typed language and it is based on Java, hence all the Java code can easily be compiled within Kotlin code. In this article, we will see how we can generate the current local date and time in Kotlin.
As Kotlin is interoperable with Java, we will be using Java utility class and Simple Date Format class in order to convert TimeStamp into DateTime.
Example – Converting DateTime using Java util class
As Kotlin is comparable with the JVM, we can use the Java util class in order to convert the TimeStamp into DateTime.
import java.text.SimpleDateFormat import java.util.* fun main(args: Array<String>) {    val simpleDate = SimpleDateFormat("dd/M/yyyy hh:mm:ss")    val currentDate = simpleDate.format(Date())    println(" Current DateTime is -"+currentDate) }  Output
On execution, it will print the current Date and Time.
Current DateTime is -28/2/2022 11:25:11
Advertisements
 