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]

我怎么做?

4

1 回答 1

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 时间。所以在我的时间里的“现在”在你的时间里是相同的毫秒。之后用它做什么就是你想用它做什么。

于 2013-10-30T15:52:34.663 回答