Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
Make sure you're using java.util.Date and not java.sql.Date -- the latter doesn't have a zero-arg constructor, and has somewhat different semantics that are the topic of an entirely different conversation. :)
Okay, not that hard as there are several methods to do this. I assume you want to put the current date & time into a TextView.
String currentDateTimeString = java.text.DateFormat.getDateTimeInstance().format(new Date());
// textView is the TextView view that should display it
textView.setText(currentDateTimeString);
There is more to read in the documentation that can easily be found here
. There you'll find more information on how to change the format used for conversion.
Best Answer
You could use:
There are plenty of constants in Calendar for everything you need.
Check the Calendar class documentation.