This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
From this code, one thing that stand out to me is that the endTime is the start time plus the difference between the start time and end time, so that part should look like this:
and considering the output you are looking for, I would suggest using the SimpleDateFormat class to do your parsing/formating.
Although this use assumes all the times you wish to parse are in the 24 hour format.
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Joined: Feb 28, 2006
Hello Keith Lynn and Garrett Rowe, strange that it doesn't compile or run wrong on your machines, because I sartet it on another machine and it compiled and run well (did a copy and paste from this site):
C:\Temp>java -version java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
C:\Temp>java timstampDemo 23:01:04
It's a Windows XP SP2 and the locale is german ...
I'am afraid I was misunerstood: Let's say I recorded a time since the start of an event, so just 59 seconds passed since the start. Now I just want to add to this 59 seconds another 5 seconds. So wath I get are 64 seconds, but we don't speak of 64 seconds, we say "One minute and four seconds". That's it: 1:04 or in a given format of HH:mm:ss -> 00:01:04
That's what I want. By the way, using the SimpleDateFormat class the result is the same, as you can see from my quote.
So, what do you think is wrong here, and - more important - how can I convince java to do what I want?
Joined: Feb 28, 2006
I've got it!
... and must admit that I'soooo 'asinine'
I didn't realise that time in java is relative to the 1.1.1970 !!! So what I did was adding a _day_ to another, resulting perhaps in a day in the fututre ... I really was !!!
I just have to add 5 seconds. That is adding 5000 millisekonds. This does the trick:
Sometimes talking about a problem is like clening your glasses. Thanx Ranch!