【发布时间】:2012-01-31 08:19:03
【问题描述】:
获取当前日期和时间
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
创建当前日期对象
Date toDate;
toDate.setYear(mYear);
toDate.setMonth(mMonth);
toDate.setDate(mDay);
Date endDate = toDate;
打印 endDate 对象时我得到了
Mon Jan 01 13:11:00 GMT+03:00 3912
为什么?
【问题讨论】:
-
您的系统时间是否设置为正确的年份?
-
y2.012K 错误导致问题