本文介绍了如何在java.time中处理完整的句号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

中的类仅处理面向日期的药水:年,月,天。

The Period class in java.time handles only the date-oriented potion: years, months, days.

时间部分怎么样:小时,分钟,秒?

What about the time portion: hours, minutes, seconds?

我们如何解析并生成, PnYnMnDTnHnMnS ?例如,一天半: P1DT12H 。学年为九个月, P9M 。每年我都会有两周零3天的假期, P17D 。客户占用了酒店房间2天17个半小时, P2DT17H30M

How can we parse and generate string representations of full periods as defined in ISO 8601, PnYnMnDTnHnMnS? For example, a day and a half: P1DT12H. The academic year is nine months, P9M. Every year I get two weeks and 3 days of vacation, P17D. The customer occupied the hotel room for 2 days and seventeen and a half hours, P2DT17H30M.

a href =http://www.joda.org/joda-time/> Joda-Time 处理整个期间。为什么不在java.time?还有其他一些机制吗?

The Period class in Joda-Time handles full period. Why not in java.time? Is there some other mechanism?

推荐答案

org.threeten.extra.PeriodDuration



项目提供了一个结合期间期限的课程。简称。

org.threeten.extra.PeriodDuration

The ThreeTen-Extra project offers a class combining a Period and a Duration. Simply called PeriodDuration.

此课程根据期间和持续时间对数量或时间进行建模。期间是基于日期的时间量,包括年,月和日。持续时间是基于时间的时间量,包括秒和纳秒。有关更多详细信息,请参阅期间和持续时间类别。

This class models a quantity or amount of time in terms of a Period and Duration. A period is a date-based amount of time, consisting of years, months and days. A duration is a time-based amount of time, consisting of seconds and nanoseconds. See the Period and Duration classes for more details.

一段时间内的天数考虑了夏令时变化(23或25小时)。执行计算时,首先添加期间,然后添加持续时间。

The days in a period take account of daylight saving changes (23 or 25 hour days). When performing calculations, the period is added first, then the duration.

警告:请务必阅读,了解尝试合并期间和持续时间。在实践中这样做很少有意义,尽管这与我们的直觉相反。

Caveat: Be sure to read the Answer by JodaStephen to understand the issues involved in trying to combine Period and Duration. It rarely makes sense to do so in practice, though that is counter to our intuition.

这篇关于如何在java.time中处理完整的句号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 10:02