- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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
- Related Articles
- How to convert timestamp to datetime in MySQL?
- How to convert MySQL datetime to Unix timestamp?
- How to convert timestamp string to datetime object in Python?
- How do I convert a datetime to a UTC timestamp in Python?
- Pandas - Convert a Timestamp object to a native Python datetime object
- How to convert JavaScript datetime to MySQL datetime?
- How to convert from Unix timestamp to MySQL timestamp value?
- Convert MySQL timestamp to UNIX Timestamp?
- How to convert date to timestamp in MongoDB
- How to Convert Text Datetime Format to Real Datetime Format in Excel?
- How to convert date to datetime in Python?
- PHP timestamp to HTML5 input type=datetime element
- How to Convert yyyymmddhhmmss Date Format to Normal Datetime in Excel?Datetime in Excel?
- How to convert DateTime to a number in MySQL?
- How to convert Python date to Unix timestamp?

Advertisements