简体   繁体   中英

Calendar.getInstance() return DayOfWeek and Dates different from the current

I have gotten Calendar class to work in my application, but the calendar does not correctly return current date and time. For instance, the date returned from this class changes earlier than the actual time ( I am in East Coast of US, so I use EST )

I want the Calendar to return EST, and the Calendar.getInstance seems to return time/date of a different time zone.

Does anyone know how to set the calendar to the date and time of the US East Coast (EST)?

(also for day of the Week, 1 is Sunday, 2 is Monday and so on right? This does not match with the current day of the week. I suppose I could arrage the number and assume 1 is Wednesday, 2 is thursday in order to make the Week day appear in my textView correctly, but what are 1 ~ 7 numbers mean, in default?)

您可以在创建日历实例时设置时区。

Calendar c = Calendar.getInstance(TimeZone.getTimeZone("EST"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM