aspose file tools
The moose likes Beginning Java and the fly likes using date as condition Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "using date as condition" Watch "using date as condition" New topic
Author

using date as condition

mitti sharma
Greenhorn

Joined: Sep 27, 2007
Posts: 5
I have to use date as a condition

like this
if "thisdate" < date =< "thisanotherdate"
// here date is wht i am reading from input line and thisdate and thisanotherdate are the boudaries between what i need to pick data from my input file.

thank you.
Bala jee
Ranch Hand

Joined: Sep 22, 2007
Posts: 35
Can you expain what exactly you need us to tell? Like do you want a code to compare two dates? what is happening when you run your program?
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

You can use Date object. It implements Comparable interface, so should able to use compareTo().


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
mitti sharma
Greenhorn

Joined: Sep 27, 2007
Posts: 5
i have to extract date and get/post from apache log comman format
(194.116.215.20 - - [14/Nov/2005:22:28:57 +0000] "GET / HTTP/1.0" 200 16440)
and then i have to count no of Gets and Posts within particular dates.
so in my program i am able to extract the dates but then i am not able to put the condition for which i need no of counts.

I can post my code if that will make more sense.
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12953
    
    3

Do you get the dates as strings? You can use class java.text.SimpleDateFormat to parse the strings into java.util.Date objects. Then you can use methods before() and after() in class Date to check if one date is before or after another date.

Lookup SimpleDateFormat and Date in the Java API documentation.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10043
    
    6

note that java does not allow you to do

you have to break it up like so:


Never ascribe to malice that which can be adequately explained by stupidity.
mitti sharma
Greenhorn

Joined: Sep 27, 2007
Posts: 5
Thanks all for replies.putting together all thoughts i made through this.
I did use SimpleDateFormat and Date.
once again thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using date as condition
 
Similar Threads
Loops in a user defined date class
Date not fully replaced by Calendar?
Remove dates from an array list using iterator
NullPointerException
How to keep the selected value ?