| Package | Description | 
|---|---|
| javax.xml.datatype | XML/Java Type Mappings. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| abstract Duration | Duration. add(Duration rhs)Computes a new duration whose value is  this+rhs. | |
| abstract Duration | Duration. multiply(BigDecimal factor)Computes a new duration whose value is  factortimes
 longer than the value of this duration. | |
| Duration | Duration. multiply(int factor)Computes a new duration whose value is  factortimes
 longer than the value of this duration. | |
| abstract Duration | Duration. negate()Returns a new  Durationobject whose
 value is-this. | |
| abstract Duration | DatatypeFactory. newDuration(boolean isPositive,
           BigInteger years,
           BigInteger months,
           BigInteger days,
           BigInteger hours,
           BigInteger minutes,
           BigDecimal seconds)Obtain a new instance of a  Durationspecifying theDurationas isPositive, years, months, days, hours, minutes, seconds. | |
| Duration | DatatypeFactory. newDuration(boolean isPositive,
           int years,
           int months,
           int days,
           int hours,
           int minutes,
           int seconds)Obtain a new instance of a  Durationspecifying theDurationas isPositive, years, months, days, hours, minutes, seconds. | |
| abstract Duration | DatatypeFactory. newDuration(long durationInMilliSeconds)Obtain a new instance of a  Durationspecifying theDurationas milliseconds. | |
| abstract Duration | DatatypeFactory. newDuration(String lexicalRepresentation)Obtain a new instance of a  Durationspecifying theDurationas its string representation, "PnYnMnDTnHnMnS",
 as defined in XML Schema 1.0 section 3.2.6.1. | |
| Duration | DatatypeFactory. newDurationDayTime(boolean isPositive,
                  BigInteger day,
                  BigInteger hour,
                  BigInteger minute,
                  BigInteger second)Create a  Durationof typexdt:dayTimeDurationusing the specifiedday,hour,minuteandsecondas defined in
 
   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration. | |
| Duration | DatatypeFactory. newDurationDayTime(boolean isPositive,
                  int day,
                  int hour,
                  int minute,
                  int second)Create a  Durationof typexdt:dayTimeDurationusing the specifiedday,hour,minuteandsecondas defined in
 
   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration. | |
| Duration | DatatypeFactory. newDurationDayTime(long durationInMilliseconds)Create a  Durationof typexdt:dayTimeDurationusing the specified milliseconds as defined in
 
   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration. | |
| Duration | DatatypeFactory. newDurationDayTime(String lexicalRepresentation)Create a  Durationof typexdt:dayTimeDurationby parsing itsStringrepresentation,
 "PnDTnHnMnS", 
   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration. | |
| Duration | DatatypeFactory. newDurationYearMonth(boolean isPositive,
                    BigInteger year,
                    BigInteger month)Create a  Durationof typexdt:yearMonthDurationusing the specifiedyearandmonthas defined in
 
   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration. | |
| Duration | DatatypeFactory. newDurationYearMonth(boolean isPositive,
                    int year,
                    int month)Create a  Durationof typexdt:yearMonthDurationusing the specifiedyearandmonthas defined in
 
   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration. | |
| Duration | DatatypeFactory. newDurationYearMonth(long durationInMilliseconds)Create a  Durationof typexdt:yearMonthDurationusing the specified milliseconds as defined in
 
   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration. | |
| Duration | DatatypeFactory. newDurationYearMonth(String lexicalRepresentation)Create a  Durationof typexdt:yearMonthDurationby parsing itsStringrepresentation,
 "PnYnM", 
   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration. | |
| abstract Duration | Duration. normalizeWith(Calendar startTimeInstant)Converts the years and months fields into the days field
 by using a specific time instant as the reference point. | |
| Duration | Duration. subtract(Duration rhs)Computes a new duration whose value is  this-rhs. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| abstract Duration | Duration. add(Duration rhs)Computes a new duration whose value is  this+rhs. | |
| abstract void | XMLGregorianCalendar. add(Duration duration)Add  durationto this instance. | |
| abstract int | Duration. compare(Duration duration)Partial order relation comparison with this  Durationinstance. | |
| boolean | Duration. isLongerThan(Duration duration)Checks if this duration object is strictly longer than
 another  Durationobject. | |
| boolean | Duration. isShorterThan(Duration duration)Checks if this duration object is strictly shorter than
 another  Durationobject. | |
| Duration | Duration. subtract(Duration rhs)Computes a new duration whose value is  this-rhs. | 
 Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2025, Oracle and/or its affiliates.  All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.