Iso duration




















Though ISO allows fractions in the lowest order component, Java only allows fractions in seconds. Yes, it is a correct representation. Test using Java-8 standard library java. Demo: import java. Pang 8, gold badges 82 82 silver badges bronze badges. Raja Ehtesham Raja Ehtesham 4 4 silver badges 7 7 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.

Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. If there are possible complications around copyright, patents or conformity assessment they should be raised at this early stage.

This stage can be skipped for revisions and amendments to ISO standards that are already published as long as the scope does not change. Usually a working group WG is set up by the parent committee to prepare the working draft WD. The WG is made up of experts and a Convenor usually the Project leader. During this stage, experts continue to look out for issues around copyright, patents and conformity assessment.

Successive WDs can be circulated until the experts are satisfied that they have developed the best solution they can. The draft is then forwarded to the WG's parent committee who will decide which stage to go to next Committee stage or Enquiry stage. For tips on writing standards see our new document How to Write Standards.

This stage is optional. During this stage the draft from the working group is shared with the members of the parent committee. The ISO standard defines an internationally recognized format for representing dates and times. For times, they are expressed with the notation hours-minutes-seconds. In the case of dates, the format is year-month-day. This basic format enables the numbers to be written directly after another.

For greater clarity, they can also be separated by delimiters. Times are divided into hours, minutes, and seconds. An ISO timestamp would therefore be: The representation of ISO date formats does away with the need for country-specific notations, at least in electronic formats.

This way, time and date information is standardized, resulting in fewer communication issues. A duration that begins on September 6, at pm and lasts one month, five days, and three hours would be expressed per the ISO standard as follows: T20P1M5T3H.

According to the ISO standard, all values like times, dates or durations are shown in a certain order: They start with the largest unit and proceed to the next smaller value. It corresponds with the natural mathematic value of numbers. Larger units are therefore always written before smaller units. This is advantageous as it means the lexicographical and chronological sorting of dates and times will produce the same result.

Parameters: millisToAdd - the milliseconds to add, positive or negative Returns: a Duration based on this duration with the specified milliseconds added, not null Throws: ArithmeticException - if numeric overflow occurs plusNanos public Duration plusNanos long nanosToAdd Returns a copy of this duration with the specified duration in nanoseconds added. Parameters: nanosToAdd - the nanoseconds to add, positive or negative Returns: a Duration based on this duration with the specified nanoseconds added, not null Throws: ArithmeticException - if numeric overflow occurs minus public Duration minus Duration duration Returns a copy of this duration with the specified duration subtracted.

Parameters: duration - the duration to subtract, positive or negative, not null Returns: a Duration based on this duration with the specified duration subtracted, not null Throws: ArithmeticException - if numeric overflow occurs minus public Duration minus long amountToSubtract, TemporalUnit unit Returns a copy of this duration with the specified duration subtracted.

Parameters: amountToSubtract - the amount to subtract, measured in terms of the unit, positive or negative unit - the unit that the amount is measured in, must have an exact duration, not null Returns: a Duration based on this duration with the specified duration subtracted, not null Throws: ArithmeticException - if numeric overflow occurs minusDays public Duration minusDays long daysToSubtract Returns a copy of this duration with the specified duration in standard 24 hour days subtracted.

The number of days is multiplied by to obtain the number of seconds to subtract. Parameters: daysToSubtract - the days to subtract, positive or negative Returns: a Duration based on this duration with the specified days subtracted, not null Throws: ArithmeticException - if numeric overflow occurs minusHours public Duration minusHours long hoursToSubtract Returns a copy of this duration with the specified duration in hours subtracted.

The number of hours is multiplied by to obtain the number of seconds to subtract. Parameters: hoursToSubtract - the hours to subtract, positive or negative Returns: a Duration based on this duration with the specified hours subtracted, not null Throws: ArithmeticException - if numeric overflow occurs minusMinutes public Duration minusMinutes long minutesToSubtract Returns a copy of this duration with the specified duration in minutes subtracted. The number of hours is multiplied by 60 to obtain the number of seconds to subtract.

Parameters: minutesToSubtract - the minutes to subtract, positive or negative Returns: a Duration based on this duration with the specified minutes subtracted, not null Throws: ArithmeticException - if numeric overflow occurs minusSeconds public Duration minusSeconds long secondsToSubtract Returns a copy of this duration with the specified duration in seconds subtracted. Parameters: secondsToSubtract - the seconds to subtract, positive or negative Returns: a Duration based on this duration with the specified seconds subtracted, not null Throws: ArithmeticException - if numeric overflow occurs minusMillis public Duration minusMillis long millisToSubtract Returns a copy of this duration with the specified duration in milliseconds subtracted.

Parameters: millisToSubtract - the milliseconds to subtract, positive or negative Returns: a Duration based on this duration with the specified milliseconds subtracted, not null Throws: ArithmeticException - if numeric overflow occurs minusNanos public Duration minusNanos long nanosToSubtract Returns a copy of this duration with the specified duration in nanoseconds subtracted.

Parameters: nanosToSubtract - the nanoseconds to subtract, positive or negative Returns: a Duration based on this duration with the specified nanoseconds subtracted, not null Throws: ArithmeticException - if numeric overflow occurs multipliedBy public Duration multipliedBy long multiplicand Returns a copy of this duration multiplied by the scalar.

Parameters: multiplicand - the value to multiply the duration by, positive or negative Returns: a Duration based on this duration multiplied by the specified scalar, not null Throws: ArithmeticException - if numeric overflow occurs dividedBy public Duration dividedBy long divisor Returns a copy of this duration divided by the specified value.

Parameters: divisor - the value to divide the duration by, positive or negative, not zero Returns: a Duration based on this duration divided by the specified divisor, not null Throws: ArithmeticException - if the divisor is zero or if numeric overflow occurs negated public Duration negated Returns a copy of this duration with the length negated. This method swaps the sign of the total length of this duration. For example, PT1. Returns: a Duration based on this duration with the amount negated, not null Throws: ArithmeticException - if numeric overflow occurs abs public Duration abs Returns a copy of this duration with a positive length.

This method returns a positive duration by effectively removing the sign from any negative total length. For example, PT Returns: a Duration based on this duration with an absolute length, not null Throws: ArithmeticException - if numeric overflow occurs addTo public Temporal addTo Temporal temporal Adds this duration to the specified temporal object.

This returns a temporal object of the same observable type as the input with this duration added. In most cases, it is clearer to reverse the calling pattern by using Temporal. Only non-zero amounts will be added. Specified by: addTo in interface TemporalAmount Parameters: temporal - the temporal object to adjust, not null Returns: an object of the same type with the adjustment made, not null Throws: DateTimeException - if unable to add ArithmeticException - if numeric overflow occurs subtractFrom public Temporal subtractFrom Temporal temporal Subtracts this duration from the specified temporal object.

This returns a temporal object of the same observable type as the input with this duration subtracted. Specified by: subtractFrom in interface TemporalAmount Parameters: temporal - the temporal object to adjust, not null Returns: an object of the same type with the adjustment made, not null Throws: DateTimeException - if unable to subtract ArithmeticException - if numeric overflow occurs toDays public long toDays Gets the number of days in this duration.

This returns the total number of days in the duration by dividing the number of seconds by Returns: the number of days in the duration, may be negative toHours public long toHours Gets the number of hours in this duration. This returns the total number of hours in the duration by dividing the number of seconds by Returns: the number of hours in the duration, may be negative toMinutes public long toMinutes Gets the number of minutes in this duration.

This returns the total number of minutes in the duration by dividing the number of seconds by Returns: the number of minutes in the duration, may be negative toMillis public long toMillis Converts this duration to the total length in milliseconds.

If this duration is too large to fit in a long milliseconds, then an exception is thrown. If this duration has greater than millisecond precision, then the conversion will drop any excess precision information as though the amount in nanoseconds was subject to integer division by one million.

Returns: the total length of the duration in milliseconds Throws: ArithmeticException - if numeric overflow occurs toNanos public long toNanos Converts this duration to the total length in nanoseconds expressed as a long.

If this duration is too large to fit in a long nanoseconds, then an exception is thrown. Returns: the total length of the duration in nanoseconds Throws: ArithmeticException - if numeric overflow occurs compareTo public int compareTo Duration otherDuration Compares this duration to the specified Duration. The comparison is based on the total length of the durations. It is "consistent with equals", as defined by Comparable.

Overrides: equals in class Object Parameters: otherDuration - the other duration, null returns false Returns: true if the other duration is equal to this one See Also: Object. Object , System. The format of the returned string will be PTnHnMnS , where n is the relevant hours, minutes or seconds part of the duration. Any fractional seconds are placed after a decimal point i the seconds section. If a section has a zero value, it is omitted.

The hours, minutes and seconds will all have the same sign. Examples: " That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy. Skip navigation links. Object java.

Obtains a Duration representing the duration between two temporal objects.



0コメント

  • 1000 / 1000