You must explicitly request the information with Calendar
and format it with SimpleDateFormat
:
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.S").format(Calendar.getInstance().getTime())
See working on ideone .
In the issue of the question (which was later removed) says that you need timestamp , there is another simpler solution taking timestamp:
System.currentTimeMillis()
See running on ideone .
Dcoumentation .
Note that we are talking about formatting the date and time display. Internally a type date
stores all information always. If you are going to use such a data, it will always be accurate. The fact that you do not see it is a presentation problem only.