本文整理汇总了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;
}
示例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);
}