Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Comparing dates long

Just to review, you did actually check that the TEST is failing with a print as opposed to just failing to observe a

change in the vector? Note that if you don't commit the changes I'm not sure they persist ( among other things that could

go wrong, depending on how you really checked this). So, if you ran the code, cycled the power, and didn't find a change in your

vector and concluded the test failed, you may want to break it up into smaller pieces :smileyhappy:

  

 

Additionally,

1) AFAIK java doesn't normally inline except maybe for hotspot. So, rather than make repeated calls to const accessor results, just make short temps on the stack ie long date1=foo.datemaker(); This also helps avoid flakely inconsistencies when you make multiple

calls to currentTimeMillis() and expect them all to be the same :smileyhappy:

 

2) Also, you should have't to cast (long) for the accessors.

3) Avoid holding any locks when you call IO or "unknown" code of anykind, including innocuous System.out.println(). Probably not a big deal but

just avoids problems later if these statements are intended to be permanent. usually you can just synchronize around some safe short

piece of code to set flags, making mutexes or semaphores, etc

http://java.sun.com/developer/technicalArticles/J2SE/concurrency/

( fwiw, my own code is littered with examples of the type you use, I'm just suggesting this for reference).

4) If you realy mean 2 days rather than 48 hours, sure you have to remove some remainders etc.

 

 

 

 

 

 

Developer
ipcTony
Posts: 107
Registered: ‎08-08-2008
My Device: Not Specified

Re: Comparing dates long

Aha Peter you the man. its a perfect solution to my problem of listing today's orders. The "Test Code" works great. This demo does not have to be accurate down to the last second of the day. Just able to pull an order for the day and print it via bluetooth so this code will work just fine.

 

Thanks for taking the time to work out the problem.

 

Simon, I'll take a look at recommendations on sorting a vector. This could be handy for sorting the Items table. Thanks.

 

I'm off to try and solve the mistery of adding a list search. Not a must have feature in this demo. Just icing on the cake and plus I need to figure this out now as it could be useful in the future.

 

Everyone... thanks again.