Can some one please take a look, adn let me know what I am doing wrong?

please take a look at the complete code in question...

public class DateStamp {

public DateStamp() {

}

public static void main(String[] args) {

DateStamp ds = new DateStamp();

String s ="2001-07-20".trim();

ds.setThisDate(s);

}

public void setThisDate(String s) {

s = s.trim();

DateFormat df =new SimpleDateFormat("yyyy-MM-dd");

Date requiredDate=null;

Date currentDate=null;

try{

requiredDate = df.parse(s);//results here are as desired

currentDate = df.parse(getCurrentDate());//current date is one month short

}catch(ParseException pe) {

pe.printStackTrace();

}

System.err.println("below is the comparison\n");

System.err.println("Current date is ["+currentDate+"]");

System.err.println("date to be compared is["+requiredDate+"]");

System.err.println("Comparison result ["+requiredDate.compareTo(currentDate));

}

/**

* @returnCurrent time and date

*/

public String getCurrentDate() {

String currentdate = new String();

Calendar calender = new GregorianCalendar();

calender = Calendar.getInstance();

currentdate = calender.get(Calendar.YEAR) + "-" +

calender.get (Calendar.MONTH) + "-" +

calender.get(Calendar.DAY_OF_MONTH) ;

return currentdate;

}

here is the output for this program...

below is the comparison

Current date is [Wed Jun 20 00:00:00 MDT 2001]//this is my problem.it should be Fri July 20,but its not..please help some one...

date to be compared is[Fri Jul 20 00:00:00 MDT 2001]

Comparison result [1]

[1705 byte] By [me_elf] at [2007-9-26 1:18:46]
# 1

public String getCurrentDate() {

String currentdate = new String();

Calendar calender = new GregorianCalendar();

calender = Calendar.getInstance();

currentdate = calender.get(Calendar.YEAR) + "-" +

calender.get (Calendar.MONTH) + "-" +

calender.get(Calendar.DAY_OF_MONTH) ;

SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd" );

currentdate = sdf.format( new Date() );

return currentdate;

}

mchan0 at 2007-6-29 0:50:13 > top of Java-index,Core,Core APIs...
# 2
"calender.get (Calendar.MONTH)" returns 0 for January, 1 for February, and so on. Hard to believe, isn't it? That's in the "Top 10 Stupidest Things in the Java Language".
DrClap at 2007-6-29 0:50:13 > top of Java-index,Core,Core APIs...
# 3
this is crazy..any ways thanks for responses.I have worked a hack around to get my task completed..bad java..
me_elf at 2007-6-29 0:50:13 > top of Java-index,Core,Core APIs...