Java 8,为什么不是ZonedTime类? [英] Java 8, why not a ZonedTime class?

查看:204
本文介绍了Java 8,为什么不是ZonedTime类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现Java 8没有等效的 ZonedDateTime 但只能使用时间 ZonedTime 类或类似的东西)。 我知道他们包括 OffsetTime 课程,但它只存储偏移量。

I found that Java 8 doesn't have an equivalent to ZonedDateTime but to work only with Time (a ZonedTime class or something like that). I know they included the OffsetTime class, but it only stores the offset.

存储时区以及日期和时间,而不是仅存储偏移量,有助于更轻松地处理夏令时。

Storing time zones along with date and time, instead of just store the offset, helps to deal with daylight savings easier.

我不是要你给我替代品,我知道有很多方法;我只是想知道为什么不包括这样的课程,这是一个设计问题吗?或者他们发现它是多余的?

I'm not asking you to give me alternatives, I know there are many approaches; I'm just wondering why such class was not included, is it a design issue? or they just found it to be redundant?

推荐答案

介绍类 ZonedTime LocalTime 和时区(而不是简单的偏移)组成将是一个重大错误。

Introducing a class ZonedTime consisting of LocalTime and a time zone (instead of a simple offset) would be a heavy mistake.

建议的类型不包含日期。但是如果没有日期,就无法评估实际时区偏移量来将当地时间映射到任何合理的全球时间。考虑到任何夏令时,您必须拥有日期和时间。

The suggested type does not contain a date. But without a date it will not be possible to evaluate the real timezone offset to map the local time to any sensible global time. For taking into account any daylight saving aspects you must have as well a date and a time.

这篇关于Java 8,为什么不是ZonedTime类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆