Date CompareTo

2001-12-03 Thread Peter Palombi
hi all, i have a troble with a compare two date. i have made this code cx.setTime(sdf1.parse(datains)); String DataV = sdf2.format(cx.getTime()); // to display the same format DataV and id if (DataV.compareTo(id) 0){ } but itn\'t work correctly with this code i compare the first two

Re: Date CompareTo

2001-12-03 Thread Doug Turner
Problem is you are comparing two strings, not two dates. Strings should be used to display the dates, not for date arithmetic. Convert id to a Date or Calendar (depending on the type of cx), and then use the before/after/equals methods of those classes to do the comparison. At 06:14 PM 12/3/01