What time zone does Date.toString() display?

后端 未结 2 1800
梦如初夏
梦如初夏 2020-12-01 23:57

By default, what time zone does method java.util.Date.toString() display? Since a Java Date stores a given date in UTC and doesn\'t contain any explicit time zone, does

2条回答
  •  旧巷少年郎
    2020-12-02 00:37

    Does it display the default time zone for the host, or TimeZone.getDefault()?

    The latter (which is the same as the former unless you set it explicitly somewhere). However, this is information gleamed from the source code, so it should be considered an implementation detail. If you want specific repeatable behavior, you should implement it yourself.

提交回复
热议问题