我的日历日期设置为美国/太平洋时区,但是当我打印时
Calender dateCalender = getDateFromFile();
System.out.println("Calender TimeZone: " + dateCalender.getTimeZone().getDisplayName());
System.out.println("Calender : " + dateCalender.getTime());
它打印完全相同的日期/时间,但时区 IST(我来自印度)。例如它打印
Calender TimeZone: **Pacific Standard Time**
Calender : Wed Oct 09 00:00:00 **IST** 2013
我尝试使用调试器并尝试查看它显示的 dateCalender 值
java.util.GregorianCalendar[time=1381257000000,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="US/Pacific",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=US/Pacific,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2013,MONTH=9,WEEK_OF_YEAR=41,WEEK_OF_MONTH=2,DAY_OF_MONTH=9,DAY_OF_YEAR=282,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=2,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=19800000,DST_OFFSET=0]
我不明白 Calender 的这种行为getTime
。请让我知道如何以相同时区格式打印日期。