|
-
May 3rd, 2000, 06:40 AM
#1
Problem to handle long
I had some problem to display a long number
with a g.drawstring command. Can somebody help ?
for example in the following codes :
Date earlierDate = new Date(71,7,1,7,10);
long earliersecs = earlierDate.getTime();
public void paint(Graphics g) {
g.drawString(earliersecs,10,50);
}
The compiler replies with an error because
earliersecs is a long. How do I solve this problem
to display a long in an applet ?
-
May 3rd, 2000, 08:19 AM
#2
Re: Problem to handle long
DavidChew,
You simply need to convert the long to a String object.
The Graphics.drawString() method takes a String only.
Do this ate earlierDate = new Date(71,7,1,7,10);
long earliersecs = earlierDate.getTime();
public void paint(Graphics g) {
String earlierSecsString = Long.toString(earliersecs);
g.drawString(earlierSecsString ,10,50);
}
This should work for you.
Look at the API for the java.util.* classes for different type conversions. They are really handy.
Regards,
dogBear
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|