Getting the time ( seconds ) that an object is active..
Hi,
I'm making a very basic game in java,
and I would like to know how long someone is active in my game..
so I will need some kind of counter thats starts counting when
when someone starts the game, this is what I have:
but for some kind of reason my gameTime is always 0...
What's wrong with my code:
class Application:
Game activeGame;
Timer timer;
TimerTask playTime;
timer = new Timer();
activeGame = new Game( id, name, .. )
playTime = new TimerTask() {
public void run()
activeGame.setGameTime();
System.println( Long.toString( activeGame.getGameTime()) );
timer.schedule( playTime, 0, 1000 );
Class Game:
private long gameTime;
public long getGame() { return this.gameTime; }
public void setGameTime() { this.gameTime += this.gameTime; }
Thanks in advance.
dBaser
in the following code:
private long gameTime;
public long getGame() { return this.gameTime; }
public void setGameTime() { this.gameTime +=
this.gameTime; }
..Where would gameTime ever be non zero? Maybe I am
missing something in your thread business in the other
class, but just looking at this I can't see where you
would get a non-zero value out of it.err .. owk damned :s
mad big fool of myself here :)
forgot to set default value to one :$
sorry guys .. ;)
Similar Messages
-
I am trying to transfer my purchases from my iPhone 5 to my new Mac computer. I get the message stating that it can only be synced with one computer at a time. I have tried the 2 other ways and I get no options to transfer my purchases. Help?
If you see Devices in the big list on the left-hand side of iTunes, it should show the name of your iPhone right below it. You can right-click (or hold ctrl and left click) on the name of the iPhone there, and choose "transfer purchases from iPhone".
If you're on iTunes 11, you won't see the big list of the left until you go to the View menu at the very top (where you see iTunes/File/Edit/View/etc) and choose Show Sidebar. Then do the same thing: right-click or ctrl and left-click on the iPhone's name below Devices and "transfer purchases from iPhone".
It'll ask you to authorize the computer for your Apple ID if you haven't yet; to do that, you just type your Apple ID and password in when it asks. If it says you are not authorized but doesn't automatically give you an option to do so, then you can go to the Store menu at the very top and choose "authorize this computer". -
How do i get the time to stopping coming on and off on my black screen. is that daydream
how do i get the time to stop coming on and off on my black screen. is that daydrea
https://motorola-global-portal.custhelp.com/app/answers/prod_answer_detail/a_id/95499/p/30,6720,8882
-
How to get the time difference (in seconds) between two timestamp fields?
Hi All,
I'm exploring validation expressions in SAP MDM Data Manager version 7.1.07.245
I have two timestamp fields, suppose Update Date and Update-GDS.
What I'm trying to do is prompt a warning when:
(Update Date minus Update-GDS) is greater than or equal to zero seconds
AND
(Update Date minus Update-GDS) is less than or equal to 900 seconds
the bottomline is, Update Date must be equal or greater than to Update-GDS but Update Date must not exceed 900 seconds difference.
my initial try was:
(Update Date - Update-GDS)>=0 s AND (Update Date - Update-GDS)<=900 s
But it always returns true even the time difference between update date and update-gds is beyond the condition.
Can you please guide me through this?
Thank you very much in advance.
Regards,
~erwinHi Abhishek,
I tried your code but it always returns true.
It seems subtraction of timestamp fields do not actually get the time difference... (in seconds)
Is this possible anyway? Or is there any other better approach on this?
Thanks,
~erwin
Edited by: erwin.j.rivera on Dec 14, 2011 8:40 AM -
HOW CAN I GET THE TIME IN EXCEL SHEET USING WRITE TO MEASUREMENT INSTRUCTION
HI, I am using GET TIME IN SECONDS ,and after that i placed SECONDS TO DATE /TIME instruction ,and i had taken a write to measurement file instruction
to get the time in excel sheet. Now i am not able to connect write to measurement source to seconds to date and time output . Is there any solution.
I am attaching my VI file also.
Attachments:
TEST.vi 43 KBHi
Im using Labview 8.2. Currently it just shows the data without the time. Im not sure what to do. It works perfectly though. I just want the time to appear on my notepad along with my data
holla
Attachments:
Testing1.txt 1 KB
Untitled 231_LV80.vi 23 KB -
Set NameFor unit of work & get the Uow from that name
Hai
Its possible to give Name (or Id ) For Unit of Work after some time get Back the unit of work from the Name (or Id ) its possible
Eg
UnitOfWork uow = .
uow.setName(sample);
after some time
get the unit of work from the name (sample)
Thanks in advanceHello Chris,
Thanks for the quick response
In our Application I have the two layers Layer1 & layer2
In the Layer1 I did the following work
1) Business validation
2) Make the call to layer2 (for Insert, update, delete, fetch)
In layer2 I have TopLink coding (for Insert, update, delete, fetch)
I want to do Insert, update, delete in single Transaction.
Each and every operation (Insert, update & delete) is separate call to Layer2 from Layer1
So I must start the transaction (UOW) in Layer1 to commit and rollback.
For Eg: To delete the object, I need the UOW in layer2. But the UOW present on layer 1
unitOfWork.deleteObject(employee);
According to our Framework specification we dont want to transfer the unit of work from Layer1 to Layer2.
So I plan to give the name for UOW & get the UOW from that Name
Give the solution for this ..
Thanks in advance -
How can i get the time detail with messageDateField ?
Is there any common way of getting the time info with messageDateField ? As far as i research, there is no way of adding the time support of messageDateField such that it can be enabled by setting a parameter to true like getTime="true". Thanks.
Fatih ERSebahattin,
You can display the time component by adding the timeStyle attribute:
<onSubmitValidater>
<date dateStyle="shortish" timeStyle="short" />
</onSubmitValidater>
Unfortunately, in the current release, when you save the date, the time will be lost. We have fixed this for the next release. As a work around, you can continue the route you have chosen with a separate time field.
To get the time value in your entity object you can add a transient attribute "time" to both your VO and EO. In the UIX page, you create a field with the same name and set persistent="true". Now, the JHeadstart save process will simply send the time field to your EO through your VO, and you can use it to add the time component to your date field.
Steven davelaar. -
I can no longer charge my iPhone5 through either of my macbook pros. I get the error message that a USB device is using too much power. Can anyone help?
I reconnected the original powered hub that I thought probably caused the problem and this time it shut down the whole computer. When I rebooted everything now works perfectly. The system reset. I tried another powered hub and it didn't have the same effect so the old one is heading for the bin and with fingers crossed all systems are now working perfectly. Trying to reset PRAM or reset the SMC didn't work but causing the same power issue did. Thanks for your input though. It did get me to think what was the original cause.
Cheers
Guy -
Trying to get the time of analysis for tables in SAP
Hi all,
I'm using the update statistics command on some tables in my database.
The num_rows attribute in the user_tables is updated after that but the last_analyzed attribute is not updated correctly.
Does anyone know how ? or maybe a different way to get the time the table was analyzed ?
Thanks,
litalDear Lital,
Can you please specify the Database system you are using and the version?
Thanks
N.P.C -
Hi:
I want to use XmlParser in my J2ME application, but at the time of defining XmlParser object i a getting error is:"XmlParser cannot be resolved to a type". I am using eclipse for developing application. I have already added KXml.zip in my src folder.
I have imported following things:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.rms.*;
import org.kxml.*;
import org.kxml.parser.*;
and actual error line is:
byte[] xmlByteArray = str.getBytes();
ByteArrayInputStream xmlStream = new ByteArrayInputStream(xmlByteArray);
InputStreamReader xmlReader = new InputStreamReader( xmlStream );
//error line XmlParser parser = new XmlParser( xmlReader );
So, can anybody help me.
Thank YouHi AnupDesai.
I'm using [kXML 2|http://kxml.sourceforge.net/kxml2/] parser, so maybe this could help you. I'm using NetBeans 6.5 and to use it I had to add the JAR file into the "resources" of my project. Then I simply use three imports:
import org.kxml2.io.KXmlParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;And use it like this:
KXmlParser parser = new KXmlParser();
InputStreamReader reader = (open your streeam here);
parser.setInput(reader)I hope this helps you!
Marc -
How to write a query to get the time difference of two varchar type time columns
Hi,
I want to get the time difference between the two varchar type columns.please see the attached image for more details:
My requirement is like:
timestarted
timeended
timediff
9:00:00
10:00:00
1:00
9:15
9:30:00
0:15Storing time alone as VARCHAR2 value is a incorrect design. Always store it as DATE or TIMESTAMP.
If you already have a messed up design and cant change it, then you need to convert your VARCHAR2 time into a DATE or TIMESTAMP and find the difference. I have converted it to TIMESTAMP and obtained the difference as INTERVAL.
SQL> with t
2 as
3 (
4 select '09:00:00' timestarted, '10:00:00' timeended from dual
5 union all
6 select '09:15:00' timestarted, '09:30:00' timeended from dual
7 )
8 select timestarted
9 , timeended
10 , (timeended - timestarted) day to second diff
11 from (
12 select to_timestamp('01011900' || timeended, 'ddmmyyyyhh24:mi:ss') timeended
13 , to_timestamp('01011900' || timestarted, 'ddmmyyyyhh24:mi:ss') timestarted
14 from t
15 );
TIMESTARTED TIMEENDED DIFF
01-JAN-00 09.00.00.000000000 AM 01-JAN-00 10.00.00.000000000 AM +00 01:00:00.000000
01-JAN-00 09.15.00.000000000 AM 01-JAN-00 09.30.00.000000000 AM +00 00:15:00.000000
SQL> -
How to get the Time Stamp if we use User Status
Hi Gurus,
We used User Status to control several Orders. Now we are required to get the "time stamp" when we change from one status to another, is that information available in the system?
If not, how do we get the time when a user status is changed from one to another?
please advice,Hi,
To check such kind of changes you have to follow below path,
Go to Status tab (Blue Ikon) --- >Extra -> Change Documents-> All- --- > Choose All Changes
SAP note 390635 provide the possibility to write change records for process and production orders as modification.
please refer this link also,
[Link|https://www.sdn.sap.com/irj/sdn/profile?userid=3781605]
Regards,
R.Brahmankar -
How to get the time length from send record command to record video really?
I have two buttons. Record/Stop
I press Record button to record the video and press Stop
button to stop recording.Now,I spend 1986 ms from press Record
button to press Stop button.
But the flv file's length is 1920 or 1910 or 1915 ms.
So I want to get the time length from send record command to
record video really.
Can you give me some suggests.
Thanks!maybe you have lag in publishing.... are you try watch de
NetStream.liveDelay() method?
or start counting when NetStream.onStatus has
"NetStream.Record.Start" and "NetStream.Record.Stop" in information
objects.... -
Majority of times when I search for a particular web site I get the error message that states that "Firefox cannot find the server at ... " (site I am looking for)
I still have the problem although I uninstalled Mozilla (clearing the cache didn't work and neither did Word diagnostics), so have ended up thinking it could be Norton (the manual update worked x1) or Windows. Today I found an answer: disable the preview pane in Windows Explorer - there's a history of problems with this view.
-
How can I get the time for a simulate signal express vi waveform?
I tried converting to an array and then indexing, but every index I try only gives me the y value. See attached VI for clarification on what I mean.
Attachments:
simulate signal.vi 49 KBYou will have to keep track of that yourself. You are sampling at 360kHz. This means that each sample is ~2.8us. You can easily get the time by taking that dt (2.8us) multiplied by the sample index and adding the time at which the first sample was taken.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Maybe you are looking for
-
Error Report... Interval Since Last Panic Report: 49701 sec Panics Since Last Report: 2 Anonymous UUID: 42E3FCD3-48FC-E0DF-C72E-5D53F896CA18 Sat Sep 21 09:41:37 2013 panic(cpu 0 caller 0xffffff801a8b8945): Kernel trap at
-
About Adobe Interactive Form license price
Hello experts, We need to develop some Adobe Interactive Form with Netweaver Developer Studio . I know that if customer create their own Adobe interactive forms then they need to purchase the license. How much the license of Adobe Interactive Form ?
-
MySQL Virtual Mail Aliases with OS X Server (10.8)?
Has anyone been able to set OS X Mountain Lion Server up with virtual mail aliases and MySQL virtual-mysql-*.conf mappings?
-
DFM Error after Upgrade from LMS 3.1 to LMS 3.2
Hi Cisco Community, I have a big problem with the LMS Application Device Fault Manager 3.2.0 after an Upgrade from LMS 3.1 to LMS 3.2 The LMS upgrade finished without error. The Alerts and Activities Diplay encountered an error with the following me
-
Strange 'Top Window' behavior in L8
I've noticed this one for a while - curious if it's a common 'bug'. When L8 is open and I switch to another app, like Safari for example, sometimes one or two of Logic's plugin windows will remain 'on top' of my display. I have to go back and switch