Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
SimpleDateFormat
和相关的旧类是多年前由JSR 310中定义的现代Java.Time 类取代的。确定“明天”需要时区。当您穿过时区向东移动时,几天开始。
捕获通过该时区看到的当前时刻。
现在,我们有能力确定“明天”,特别是第二天的第一时刻。
提取日期部分。
获得第一个时刻。请注意,我们做不是假定一天开始于00:00
SimpleDateFormat
and related legacy classes were years ago supplanted by the modern java.time classes defined in JSR 310.Determining “tomorrow” requires a time zone. Days start earlier as you move eastward through time zones.
Capture the current moment as seen through that time zone.
Now we are in a position to determine “tomorrow”, specifically the first moment of the following day.
Extract the date portion.
Get first moment. Note that we do not assume the day starts at 00:00 ????. Some dates in some zones start at a different time of day, such as 01:00 ????. Let java.time determine the first moment.
Calculate time to elapse.
Generate text in standard ISO 8601 format.
If you insist on the risky ambiguous use of clock-time to represent the duration, you can build your own string by interrogating the
Duration
object. Call itsto…Part
methods.