日期:2014-05-16 浏览次数:20679 次
public class TimeTest { public static void main(String[] args) { //java.util.Calendar.getInstance().setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); //System.out.println(TimeZone.getDefault().getID()); System.out.println(java.util.Calendar.getInstance().getTime()); System.out.println(java.util.Calendar.getInstance().getTimeZone()); System.out.println(new Date().toLocaleString()); } } 输出结果如下: Mon Mar 17 15:18:24 CST 2008 sun.util.calendar.ZoneInfo[id="Asia/Shanghai",offset=28800000,dstSavings=0,useDaylight=false,transitions=19,lastRule=null] 2008-3-17 15:18:24