I got 2 strings. They will be in form for yyyymmdd i.e. 20030802, 20030701 I want to do 2 things 1) make sure 1st one is earlier than 2nd one 2) they are not more than 30days apart. Both will throw error. Anyone can help? thanks so much and really appreciated that.
Since you know the format(and assuming it won't vary with input)I think I'd parse the date info out and create GregorianCalendar instances. You can then use the boolean after() method(inherited from Calendar) to see if the one date is after another. Then use the DAY_OF_YEAR fields in the different GregorianCalendar instances to determine if the dates are more than 30 days apart, i.e. do a subtraction and see if the difference > 30. A lot of hoops to jump through, I realize, but I don't think there is any simple way to do this sort of thing with just String comparisons. Anybody? HTH, E
My theory of evolution is that Darwin was adopted. - Steven Wright