我将日期设置为2013-01-01 00:00:00,但日期为格林威治标准时间2月1日00:00:00 GMT + 01:00 2013
为什么?
Calendar calendar = Calendar.getInstance();
calendar.set(2013, 1, 1, 0, 0, 0);
Date startDate = calendar.getTime();
Run Code Online (Sandbox Code Playgroud)
Java编号的日期类中的月份编号从0开始.使用类中的月份常量Calendar来避免这种常见错误.
calendar.set(2013, Calendar.JANUARY, 1, 0, 0, 0);
Run Code Online (Sandbox Code Playgroud)