Java -Retrieve current date and time

October 2016


I need to display JFrame with labels and next to these labels, the date and time at which they were typed.
For this I need to retrieve and display the date and time in a JLabel but I can not even recover those below in a simple format such as: DD/MM/YYYY and HH/ MM/SS.


You must use the Date class from the java.util package
Inside, you have the Date () constructor which creates the current date. To obtain a more readable form you do a:

Date myDate = new Date();  
// Display:  

Thanks to maily for this tip.

Related :

This document entitled « Java -Retrieve current date and time » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.