• Post Reply Bookmark Topic Watch Topic
  • New Topic

get the system time(urgent)

 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I get the system time as it is displayed in the system tray.I want to display a clock in my frame and update it every second.I just don't want to create an instance of date and get the time form it.Please help me, even if it uses JNI.Urgent please.
 
Shumaiza Manzoor
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i think it will help u!
Locale locale = new Locale("pak","");

DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,locale);

fmt.setTimeZone(TimeZone.getDefault());

String st = fmt.format(new java.util.Date());
System.out.println(st);

dont forget to import java.util package.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!