我在Java的日历上遇到了一些麻烦.我正在解析txt文件中的一些数据,需要创建一个日期.完成以下代码后:
tmpYear = Double.parseDouble(row[yearIndex]);
tmpMonth = Double.parseDouble(row[monthIndex]);
tmpDay = Double.parseDouble(row[dayIndex]);
if(timeIndex != -1)
tmpTime = Double.parseDouble(row[timeIndex]);
if(secondsIndex != -1)
tmpSeconds = Double.parseDouble(row[secondsIndex]);
Run Code Online (Sandbox Code Playgroud)
我可以调试并看到变量如下:tmpYear == 2010
tmpMonth == 12
tmpDay == 30
tmpTime == 15(这是一天中的小时)
tmpSeconds == 0
但是在运行以下代码时:
cal.set((int)tmpYear,(int)tmpMonth,(int)tmpDay,(int)tmpTime,
(int)((tmpTime - (int)tmpTime)*100),(int)tmpSeconds);
System.out.println(cal.getTime().toString());
Run Code Online (Sandbox Code Playgroud)
我得到的是输出:
Sun Jan 30 15:00:00 CST 2011
有人可以解释一下可能的原因是什么吗?提前谢谢大家的帮助!