本文整理匯總了Java中javax.xml.datatype.DatatypeFactory.newDurationDayTime方法的典型用法代碼示例。如果您正苦於以下問題:Java DatatypeFactory.newDurationDayTime方法的具體用法?Java DatatypeFactory.newDurationDayTime怎麽用?Java DatatypeFactory.newDurationDayTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.datatype.DatatypeFactory
的用法示例。
在下文中一共展示了DatatypeFactory.newDurationDayTime方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testNewDurationDayTimeLexicalRepresentation
import javax.xml.datatype.DatatypeFactory; //導入方法依賴的package包/類
@Test
public void testNewDurationDayTimeLexicalRepresentation() throws DatatypeConfigurationException {
DatatypeFactory dtf = DatatypeFactory.newInstance();
Duration d = dtf.newDurationDayTime("P1DT23H59M65S");
int days = d.getDays();
Assert.assertTrue(days == 2, "Return value should be normalized");
}
示例2: testNewDurationDayTimeMilliseconds
import javax.xml.datatype.DatatypeFactory; //導入方法依賴的package包/類
@Test
public void testNewDurationDayTimeMilliseconds() throws DatatypeConfigurationException {
DatatypeFactory dtf = DatatypeFactory.newInstance();
Duration d = dtf.newDurationDayTime(172805000L);
int days = d.getDays();
Assert.assertTrue(days == 2, "Return value should be normalized");
}
示例3: testNewDurationDayTimeBigInteger
import javax.xml.datatype.DatatypeFactory; //導入方法依賴的package包/類
@Test
public void testNewDurationDayTimeBigInteger() throws DatatypeConfigurationException {
DatatypeFactory dtf = DatatypeFactory.newInstance();
BigInteger day = new BigInteger("1");
BigInteger hour = new BigInteger("23");
BigInteger min = new BigInteger("59");
BigInteger sec = new BigInteger("65");
Duration d = dtf.newDurationDayTime(true, day, hour, min, sec);
int days = d.getDays();
System.out.println("Days: " + days);
Assert.assertTrue(days == 2, "Return value should be normalized");
}
示例4: testNewDurationDayTimeInt
import javax.xml.datatype.DatatypeFactory; //導入方法依賴的package包/類
@Test
public void testNewDurationDayTimeInt() throws DatatypeConfigurationException {
DatatypeFactory dtf = DatatypeFactory.newInstance();
Duration d = dtf.newDurationDayTime(true, 1, 23, 59, 65);
int days = d.getDays();
System.out.println("Days: " + days);
Assert.assertTrue(days == 2, "Return value should be normalized");
}
示例5: newDurationDayTimeTester
import javax.xml.datatype.DatatypeFactory; //導入方法依賴的package包/類
private void newDurationDayTimeTester(boolean isPositive, boolean normalizedIsPositive, BigInteger years, BigInteger normalizedYears, BigInteger months,
BigInteger normalizedMonths, BigInteger days, BigInteger normalizedDays, BigInteger hours, BigInteger normalizedHours, BigInteger minutes,
BigInteger normalizedMinutes, BigDecimal seconds, BigDecimal normalizedSeconds, long durationInMilliSeconds, long normalizedDurationInMilliSeconds,
String lexicalRepresentation, String normalizedLexicalRepresentation) {
DatatypeFactory datatypeFactory = null;
try {
datatypeFactory = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException ex) {
ex.printStackTrace();
Assert.fail(ex.toString());
}
// create 4 dayTime Durations using the 4 different constructors
Duration durationDayTimeBigInteger = datatypeFactory.newDurationDayTime(isPositive, days, hours, minutes, seconds.toBigInteger());
durationAssertEquals(durationDayTimeBigInteger, DatatypeConstants.DURATION_DAYTIME, normalizedIsPositive, normalizedYears.intValue(),
normalizedMonths.intValue(), normalizedDays.intValue(), normalizedHours.intValue(), normalizedMinutes.intValue(), normalizedSeconds.intValue(),
normalizedDurationInMilliSeconds, normalizedLexicalRepresentation);
/*
* Duration durationDayTimeInt = datatypeFactory.newDurationDayTime(
* isPositive, days.intValue(), hours.intValue(), minutes.intValue(),
* seconds.intValue()); Duration durationDayTimeMilliseconds =
* datatypeFactory.newDurationDayTime( durationInMilliSeconds); Duration
* durationDayTimeLexical = datatypeFactory.newDurationDayTime(
* lexicalRepresentation);
* Duration durationYearMonthBigInteger =
* datatypeFactory.newDurationYearMonth( isPositive, years, months);
* Duration durationYearMonthInt = datatypeFactory.newDurationYearMonth(
* isPositive, years.intValue(), months.intValue()); Duration
* durationYearMonthMilliseconds = datatypeFactory.newDurationYearMonth(
* durationInMilliSeconds); Duration durationYearMonthLexical =
* datatypeFactory.newDurationYearMonth( lexicalRepresentation) ;
*/
}
示例6: getShippingDuration
import javax.xml.datatype.DatatypeFactory; //導入方法依賴的package包/類
private Duration getShippingDuration() throws DatatypeConfigurationException {
DatatypeFactory factory = DatatypeFactory.newInstance();
return factory.newDurationDayTime(true, 1, 0, 0, 0); // in one day
}
開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:5,代碼來源:DhlShippingCalculationMethod.java