Java DateFormat parse() doesn't respect the timezone

后端 未结 3 1123
小蘑菇
小蘑菇 2021-01-01 21:01
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("America/New_York"));
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
df.         


        
3条回答
  •  [愿得一人]
    2021-01-01 21:17

    DateFormat is an abstract class for date/time formatting subclasses which formats and parses dates or time in a language-independent manner. The date/time formatting subclass, such as SimpleDateFormat, allows for formatting (i.e., date -> text), parsing (text -> date), and normalization. The date is represented as a Date object or as the milliseconds since January 1, 1970, 00:00:00 GMT.

    From the spec, it return EPOCH time

提交回复
热议问题