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
Posts: 80
Registered: ‎08-26-2008
My Device: 8800, 8100
Accepted Solution

Date Comparison

i want to setup a trial period mechanism in my application...

pls tell how to capture system date and how to compare two date...i mean is thr any function in BB api for comparing date?

thnx
Jeet Bhatt, India
Highlighted
Developer
Posts: 507
Registered: ‎07-15-2008
My Device: Not Specified

Re: Date Comparison

Date values stored as long values.

 

Every long date representation is qty of milliseconds passed from 01 jan 1970 00:00.

 

To compare two dates just compare two long values.

 

When your application starts for the first time (when there is no saved expiration date) - calculate and save expiration date in persistent store.

 

One day length in milliseconds is represented via constant in DateTimeUtitlities class. Or you may calculate it by yourselft.

----------------
if your issue solved set "Solution" mark at the relevant post
Developer
Posts: 80
Registered: ‎08-26-2008
My Device: 8800, 8100

Re: Date Comparison

i think u've pointed me to the right direction..let me work on it.. thanks a lot

if any further issue arise..i'll post it here or send a msg to u.

Jeet Bhatt, India
Developer
Posts: 80
Registered: ‎08-26-2008
My Device: 8800, 8100

Re: Date Comparison

thnx Rafo. its done..Smiley Happy

Jeet Bhatt, India
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Date Comparison

I'm working on cookie code and was expecting to find some group of methods

to take the expiriation date and convert it to a long for the netscape cookie file format ( as well as the obvious expiration test).

Is there a simple method or do I have to make a field array and do it a piece at a time? As far as that goes, it looked

like the string utilities parsed words and would choke on numeric data. Is there something, if needed, that breaks

a string on spaces into a String[] of words/numbers/symbolsgroups?

 

Thanks.

 

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

Re: Date Comparison

To answer my own question, it looks like the net.rim.device.api.io.http.HttpDateParse class does what

I need in parsing an http date into a long that can be used for cache control.

 

But, I'm not sure this can be used to generate http dates from a long and the format of Date.toString() didn;t

look right when I tried it.

 

Developer
Posts: 80
Registered: ‎08-26-2008
My Device: 8800, 8100

Re: Date Comparison

sorry i didnt get exactly. do u want date in normal/traditional date format rather than long value. for comparision?
Jeet Bhatt, India
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Date Comparison

I'm trying to convert a long into something like this,

 

expires=Fri, 03-Sep-2038 19:06:33 GMT

 

but I get something like this from Date.toString()

 

Wed Sep 10 15:06:56 America/New_York 2008

 

and it wasn't immediately obvious how to change the format without perhaps going through the field things. I thought there may be

a utility to convert long to the http format,

// We need to try an "If-modified-since" for normal caching,
     // and of course we can handle background loading.
     // http://www.ietf.org/rfc/rfc2616.txt?number=2616

Developer
Posts: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

Re: Date Comparison

I have a doubht. IF i set the trial mechanism and store the date by executing system.currentmillis(), would i save the current system date?

 

if thats the case what wil happen if i store the date and then customer changes the date to a date previous to the stored date.that would make the trial mechanism worthless isnt it? whats the work around? thanks,.

Developer
Posts: 342
Registered: ‎02-04-2009
My Device: BB 8320

Re: Date Comparison

[ Edited ]

One more thought.

 

We can save the current system time while installing and every day we can even keep maintaining the current day on one more property. Hence, once the system passed a day and the user purposepully change the system date to old date, we can alert the user that the system date has been back-dated and exit the application.

 

But the bad side is, if the user changes his system to future date and came back to current date also, our application won't allow the user to use our application.

 

Any other efficient way to handle the Trial validation effectively?

 

Thanks. 

Message Edited by baskaraninfo on 04-27-2009 06:15 AM

Use Search. "Accept Solution" if the problem gets resolved.