Messenger569
asked on
Dates in Java
I've watched the following code execute, and every time I check the date of expiration after this executes, I get something like:
Wed Feb 01 00:00:00 CST 3905
Actually, I'm getting this same date every time it executes. The values for Year and Month are (2005, 1) respectively.
Wed Feb 01 00:00:00 CST 3905
Actually, I'm getting this same date every time it executes. The values for Year and Month are (2005, 1) respectively.
String strMonth = request.getParameter("txtMonth");
String strYear = request.getParameter("txtYear");
int Month = Integer.parseInt(strMonth);
int Year = Integer.parseInt(strYear);
Date expiration = new Date(Year, Month, 1,0 ,0 );
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry I didnt see previous responce.
Actually, the above constructors are deprecated. More correct would be:
Date expiration = ( new GregorianCalendar(Year, Month-1, 1) ).getTime();
Date expiration = ( new GregorianCalendar(Year, Month-1, 1) ).getTime();
Date expiration = new Date(Year-1900, Month, 1,0 ,0 );