Link to home
Start Free TrialLog in
Avatar of g46905
g46905

asked on

Using date properties?

I want to read a file if it is created between a particular period.The user selects the from and to fields.We compare these two fields with the date in the file.

This is what I am currently doing...

if(rD.after(toDate) && rD.before(tfromDate)){

read the file

}

If the user enters july 01 2004 as the from field, the files are being read from july 02 2004. Can you please help me with this issue?

Thanks,
Avatar of Mick Barry
Mick Barry
Flag of Australia image

if (rD.compareTo(toDate)<=0 && rD.compareTo(tfromDate)>=0)
Avatar of g46905
g46905

ASKER

It is still not reading the file created on that partucular date.

This is what I am using

  rD : Wed Sep 01 00:00:00 CDT 2004 // the file created on the same date as fromDate is not being read.
 fromDate : Wed Sep 01 00:00:00 CDT 2004
 ToDate : Thu Sep 30 23:59:59 CDT 2004

if ((rD.compareTo(toDDDDt)<=0) && (rD.compareTo(frDDDDt)>=0))

Any ideas would be greatly appreciated.

Thanks,
can you run this and post the output:

System.out.println(rD);
System.out.println(frDDDDt);
System.out.println(toDDDDt);
System.out.println(rD.compareTo(toDDDDt));
System.out.println(rD.compareTo(frDDDDt));
Avatar of g46905

ASKER

Object,
          Here are the results that you have asked me for


 rD : Wed Sep 01 00:00:00 CDT 2004
 frDDDDt : Wed Sep 01 00:00:00 CDT 2004
 toDDDDt : Thu Sep 30 23:59:59 CDT 2004
 rD.compareTo(toDDDDt) : -1
 rD.compareTo(frDDDDt) -1

Please let me know if you want me to try something else.Thanks for your help!

Thanks again,
post the results of this:

System.out.println(rD.getTime());
System.out.println(frDDDDt.getTime());
Avatar of g46905

ASKER

System.out.println(rD.getTime());

=>  1094014800000

System.out.println(frDDDDt.getTime());

=>  1094014800219

Please lte me know if you want me to test something.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of g46905

ASKER

This is how I set the fromDate

cs.set(yyyy, mm, dd, 0, 0, 0);

Could you please share your thoughts on the changes that needs to take place to resolve the above mentioned issue.

Thanks,
Avatar of g46905

ASKER

I want the milliseconds to be a default value of 0 all the time for the fromDate. Can you please suggest?

Thanks
Avatar of g46905

ASKER

I have made the change required and was able to set the milliseconds to default 0.Thanks for all your help.

cs.set(Calendar.MILLISECOND,0);

Thanks again,
good to hear you got it resolved :)