Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I display the current Time showing on my comp in the format xx:yy:zz  RSS feed

 
sandy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
Sandy
 
Anamika Singh
Ranch Hand
Posts: 67
IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the simplest code to do so
Calendar calendar = new GregorianCalendar();
Date date = calendar.getTime();
DateFormat df=new SimpleDateFormat("dd':'MM':'yy");
//MM must be in caps else it will give the minutes
System.out.println("date is"+df.format(date))
 
sandy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Anamica , I did find a solution by using StringTokenizer and tokenizing the System date.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sandy" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

Thanks! and welcome to the JavaRanch!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!