Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Show Local Date and Time in Eclipse
Show Local Date and Time in Eclipse [message #797815] Mon, 13 February 2012 22:59 Go to next message
Pita Sivam is currently offline Pita SivamFriend
Messages: 2
Registered: February 2012
Junior Member
Hi there,

i am new to this forum and would appreciate any help.
basically i am creating a java project in eclipse and designing the interface with window builder.

on the main interface, i want a local date and time to be displayed.
I have written the code

public String getSysDate() {
Date sysDate = new Date();
String sysDateStr = sysDate.toString();
return sysDateStr;
}

First of all, is this correct?
Secondly, how do i make this date and time to be displayed in the interface ?
can i add a JLabel or something into the frame then write a code for it or such?

Please don't be too technical Smile
Thanks
Re: Show Local Date and Time in Eclipse [message #797839 is a reply to message #797815] Mon, 13 February 2012 23:50 Go to previous messageGo to next message
Pita Sivam is currently offline Pita SivamFriend
Messages: 2
Registered: February 2012
Junior Member
Hey, just to let you know, I have actually figured out how to make it work.
So yeh it displays the time and date.
But the time is now updating, unless i shut and open the window again. literally i have to refresh in order
to get the up to date time. how can i make the time flow up to date?
Re: Show Local Date and Time in Eclipse [message #797919 is a reply to message #797839] Tue, 14 February 2012 02:27 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
On 02/13/2012 05:51 PM, Pita Sivam wrote:
> Hey, just to let you know, I have actually figured out how to make it work.
> So yeh it displays the time and date.
> But the time is now updating, unless i shut and open the window again.
> literally i have to refresh in order
> to get the up to date time. how can i make the time flow up to date?
You will have to write the code to update the labels on a periodic
basis. There is nothing built into Java the will update the label
automatically. It sounds like you are new to Java development. I would
suggest you get a book on Java development or read online tutorials.

This forum is for questions related to the Java Development tools
provided by Eclipse, not for general Java development questions.
Re: Show Local Date and Time in Eclipse [message #861588 is a reply to message #797919] Sat, 28 April 2012 16:45 Go to previous message
Hans Mueller is currently offline Hans MuellerFriend
Messages: 28
Registered: April 2012
Junior Member
very good
Previous Topic:Seeing breakpoints
Next Topic:unable to launch
Goto Forum:
  


Current Time: Fri Apr 19 00:14:40 GMT 2024

Powered by FUDForum. Page generated in 0.02426 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top