當前位置: 首頁>>代碼示例>>Java>>正文


Java Duration.getSign方法代碼示例

本文整理匯總了Java中javax.xml.datatype.Duration.getSign方法的典型用法代碼示例。如果您正苦於以下問題:Java Duration.getSign方法的具體用法?Java Duration.getSign怎麽用?Java Duration.getSign使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.datatype.Duration的用法示例。


在下文中一共展示了Duration.getSign方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: durationAssertEquals

import javax.xml.datatype.Duration; //導入方法依賴的package包/類
private void durationAssertEquals(Duration duration, QName xmlSchemaType, boolean isPositive, int years, int months, int days, int hours, int minutes,
        int seconds, long milliseconds, String lexical) {

    final TimeZone GMT = TimeZone.getTimeZone("GMT");
    final GregorianCalendar EPOCH = new GregorianCalendar(GMT);
    EPOCH.clear();

    if (DEBUG) {
        System.out.println("Testing Duration: " + duration.toString());
    }

    // sign
    if (DEBUG) {
        boolean actual = (duration.getSign() == 1) ? true : false;
        System.out.println("sign:");
        System.out.println("    expected: \"" + isPositive + "\"");
        System.out.println("    actual:   \"" + actual + "\"");
    }

    if (DEBUG) {
        System.out.println("years:");
        System.out.println("    expected: \"" + years + "\"");
        System.out.println("    actual:   \"" + duration.getYears() + "\"");
    }

    if (DEBUG) {
        System.out.println("months:");
        System.out.println("    expected: \"" + months + "\"");
        System.out.println("    actual:   \"" + duration.getMonths() + "\"");
    }

    if (DEBUG) {
        System.out.println("days:");
        System.out.println("    expected: \"" + days + "\"");
        System.out.println("    actual:   \"" + duration.getDays() + "\"");
    }

    if (DEBUG) {
        System.out.println("hours:");
        System.out.println("    expected: \"" + hours + "\"");
        System.out.println("    actual:   \"" + duration.getHours() + "\"");
    }

    if (DEBUG) {
        System.out.println("minutes:");
        System.out.println("    expected: \"" + minutes + "\"");
        System.out.println("    actual:   \"" + duration.getMinutes() + "\"");
    }

    if (DEBUG) {
        System.out.println("seconds:");
        System.out.println("    expected: \"" + seconds + "\"");
        System.out.println("    actual:   \"" + duration.getSeconds() + "\"");
    }

    if (DEBUG) {
        System.out.println("milliseconds:");
        System.out.println("    expected: \"" + milliseconds + "\"");
        System.out.println("    actual:   \"" + duration.getTimeInMillis(EPOCH) + "\"");
    }

    if (DEBUG) {
        System.out.println("lexical:");
        System.out.println("    expected: \"" + lexical + "\"");
        System.out.println("    actual:   \"" + duration.toString() + "\"");
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:69,代碼來源:DurationTest.java


注:本文中的javax.xml.datatype.Duration.getSign方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。