how to get current date and time in android studio
MainActivity.java
// get current date in 03-01-2020 format
String currentDate = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(new Date());
// get current date in 03-Jan-2020 format
String currentDate2 = new SimpleDateFormat("dd-MMM-yyyy", Locale.getDefault()).format(new Date());
// get day name like Mon, Tue, Wed, etc.
String dayName = new SimpleDateFormat("E", Locale.getDefault()).format(new Date());
// get time in 12 hours
String getTime = new SimpleDateFormat("hh:mm:ss a", Locale.getDefault()).format(new Date());
// get time in 24 hours
String getTime2 = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()).format(new Date());
// get both date and time
String currentDateTime = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss", Locale.getDefault()).format(new Date());
Projects with Source Code + Video Tutorials
You can download our Java and Android Studio Projects with Source Code and Video Tutorials.
![Modern-Login-and-Register-screen-UI-design](https://learnoset.com/Learnoset/Projects/LoginRegister3/thumbnail.jpg)
Modern Login and Register screen UI design
![Programming-Quiz-App-for-Android-(Offline-Version)](https://learnoset.com/Learnoset/Projects/OflineQuiz/thumnail.jpg)
Programming Quiz App for Android (Offline Version)
![Complete-Quotes-App-for-Android](https://learnoset.com/Learnoset/Projects/QuotesApp/quotes_app.jpg)
Complete Quotes App for Android
If you have any Questions or Queries
You can mail us at info.learnoset@gmail.com
Follow us to learn Coding and get in touch with new Technologies.