hey,
im trying to parse a datetime... and im having a lot of trouble. The code i have is pretty simple, just trying to parse a string in to a Date object.
In this code, the 'datetime' variable is "01-13-2010 21:56".
After the df.parse(datetime) line, the date is "Sat Jan 01 21:56:00 GMT+00:00 2011"... which is wrong.
Then, after the calls to getYear, etc... the values are different again!
mYear = 111
mMonth = 0
mDay = 6
mHour = 21
mMinute = 56
I've tried lots of different SimpleDateFormat formats and i cannot get any to work! Any help here would be great!
im trying to parse a datetime... and im having a lot of trouble. The code i have is pretty simple, just trying to parse a string in to a Date object.
In this code, the 'datetime' variable is "01-13-2010 21:56".
After the df.parse(datetime) line, the date is "Sat Jan 01 21:56:00 GMT+00:00 2011"... which is wrong.
Then, after the calls to getYear, etc... the values are different again!
mYear = 111
mMonth = 0
mDay = 6
mHour = 21
mMinute = 56
I've tried lots of different SimpleDateFormat formats and i cannot get any to work! Any help here would be great!
Code:
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm");
if (datetime != null && !datetime.equals("")) {
Date date = df.parse(datetime);
mYear = date.getYear();
mMonth = date.getMonth();
mDay = date.getDay();
mHour = date.getHours();
mMinute = date.getMinutes();
}