I'm converting a date stored in a calendar object in a string for a query in MySQL. I need the string in format "yyyy-MM-dd HH:mm:ss", i.e.: "2010-01-01 15:30:00". I'm using a code like:
Calendar TimeStop = Calendar.getInstance();
TimeStop.set(2010, 01, 01, 15, 30, 0);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String TimeStop_Str = sdf.format(TimeStop.getTime());
now, the string, instead of being "2010-01-01 15:30:00" like I would expect is "2010-02-01 15:30:00". I have already checked on http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html for possible errors in the parser formula (for example the capital MM for month or capital HH for hours) but it didn't worked.
I guess that there is some other field that I should set, or maybe there is another method... any idea?
Thanks!