Reputation: 3
I'm trying to show date in a text field this is what I did
java.util.Date date=new java.util.Date();
this.DateObject.setText(date);
But it shows error...
Upvotes: 0
Views: 5982
Reputation: 4151
Try below code.
Date now = new Date();
//Set date format as you want
SimpleDateFormat sf = new SimpleDateFormat("dd-MM-yy");
this.DateObject.setText(sf.format(now));
Upvotes: 10
Reputation: 13709
You might need to do a toString
on it as
this.DateObject.setText(date.toString());
Upvotes: 1