Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I get a current date and time in a JLabel?

 
Aaron Parker
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't get this to compile. How do I get a date into the label?
 
Aaron Parker
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Before I had Date dateAndTime = new Date(); just above JLabel dateTime)
 
Carlos Failde
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy.
Date dateAndTime = Calendar.getInstance().getTime();
JLabel dateTime = new JLabel(dateAndTime.toString());
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic