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


Java XMLGregorianCalendar.setMinute方法代碼示例

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


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

示例1: toXMLCalendar

import javax.xml.datatype.XMLGregorianCalendar; //導入方法依賴的package包/類
public XMLGregorianCalendar toXMLCalendar(Date d) throws Exception {  
    GregorianCalendar gc = new GregorianCalendar();  
    gc.setTime(d);  
    XMLGregorianCalendar xml = DatatypeFactory.newInstance()  
            .newXMLGregorianCalendar();  
    xml.setYear(gc.get(Calendar.YEAR));  
    xml.setMonth(gc.get(Calendar.MONTH) + 1);  
    xml.setDay(gc.get(Calendar.DAY_OF_MONTH));  
    xml.setHour(gc.get(Calendar.HOUR_OF_DAY));  
    xml.setMinute(gc.get(Calendar.MINUTE));  
    xml.setSecond(gc.get(Calendar.SECOND));  
    return xml;  
}
 
開發者ID:vindell,項目名稱:docx4j-template,代碼行數:14,代碼來源:Docx4j_創建批注_S3_Test.java

示例2: checkToGregorianCalendar01

import javax.xml.datatype.XMLGregorianCalendar; //導入方法依賴的package包/類
@Test
public void checkToGregorianCalendar01() {

    XMLGregorianCalendar time_16_17_18 = datatypeFactory.newXMLGregorianCalendar("16:17:18");
    XMLGregorianCalendar date_2001_02_03 = datatypeFactory.newXMLGregorianCalendar("2001-02-03");
    GregorianCalendar calendar = date_2001_02_03.toGregorianCalendar(null, null, time_16_17_18);

    int year = calendar.get(YEAR);
    int minute = calendar.get(MINUTE);

    assertTrue((year == 2001 && minute == 17), " expecting year == 2001, minute == 17" + ", result is year == " + year + ", minute == " + minute);


    calendar = time_16_17_18.toGregorianCalendar(null, null, date_2001_02_03);

    year = calendar.get(YEAR);
    minute = calendar.get(MINUTE);

    assertTrue((year == 2001 && minute == 17), " expecting year == 2001, minute == 17" + ", result is year == " + year + ", minute == " + minute);


    date_2001_02_03.setMinute(3);
    date_2001_02_03.setYear(null);

    XMLGregorianCalendar date_time = datatypeFactory.newXMLGregorianCalendar("2003-04-11T02:13:01Z");

    calendar = date_2001_02_03.toGregorianCalendar(null, null, date_time);

    year = calendar.get(YEAR);
    minute = calendar.get(MINUTE);
    int hour = calendar.get(HOUR);

    assertTrue((year == 2003 && hour == 2 && minute == 3), " expecting year == 2003, hour == 2, minute == 3" + ", result is year == " + year + ", hour == " + hour + ", minute == " + minute);


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


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