2013-10-30 76 views
0

我需要創建一個日曆對象實例(當前時間)如何創建日曆對象與同一時區時區

java.util.GregorianCalendar[time=1383128400000,areFieldsSet=true,lenient=true, 
zone=America/New_York, 
firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2013,MONTH=9,WEEK_OF_YEAR=44, 
WEEK_OF_MONTH=5,DAY_OF_MONTH=30,DAY_OF_YEAR=303,DAY_OF_WEEK=4, 
DAY_OF_WEEK_IN_MONTH=5,AM_PM=0,HOUR=6,HOUR_OF_DAY=6,MINUTE=20,SECOND=0, 
MILLISECOND=0,ZONE_OFFSET=-18000000,DST_OFFSET=3600000] 

我該怎麼辦呢?

回答

0
Calendar c = Calendar.getInstance(); 
    System.out.println(c.getTimeZone()+" milliseconds: "+c.getTimeInMillis()); 

    c = Calendar.getInstance(TimeZone.getTimeZone("America/New_York")); 
    System.out.println(c.getTimeZone()+" milliseconds: "+c.getTimeInMillis()); 

注意:Java中的所有內容均採用GMT。所以現在在我的時間是你的時間相同的毫秒。之後做什麼就是你想要做什麼。