This was probably asked and answered a million times, but I can not find a solution anywhere. After starting the activity in the Android application, I want to display the current date and time. From what I understand, part of the date can be done simply with the following:
Date d = new Date();
d.getTime();
CharSequence s = DateFormat.format("EEEE, MMMM d, yyyy", d.getTime());
TextView date = (TextView)findViewById(R.id.dateText);
date.setText(s);
TextView time = (TextView)findViewById(R.id.timeText);
time.setText(s);
In eclipse, it gives me an error and says that the constructor date is undefined. I chose the automatic fix option, and it added 0 as a parameter in the Date constructor. This gave the date, but the date is December 31, 1969. What am I missing here?
This is probably trivial, but I'm still new to this.
Thanks in advance for any advice.
source
share