当前位置: 首页>>代码示例>>Java>>正文


Java DatatypeFactory.newXMLGregorianCalendar方法代码示例

本文整理汇总了Java中javax.xml.datatype.DatatypeFactory.newXMLGregorianCalendar方法的典型用法代码示例。如果您正苦于以下问题:Java DatatypeFactory.newXMLGregorianCalendar方法的具体用法?Java DatatypeFactory.newXMLGregorianCalendar怎么用?Java DatatypeFactory.newXMLGregorianCalendar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.datatype.DatatypeFactory的用法示例。


在下文中一共展示了DatatypeFactory.newXMLGregorianCalendar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getXMLGregorianCalendarNow

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
private XMLGregorianCalendar getXMLGregorianCalendarNow()
		throws DatatypeConfigurationException {
	GregorianCalendar gregorianCalendar = new GregorianCalendar();
	DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
	XMLGregorianCalendar now = datatypeFactory
			.newXMLGregorianCalendar(gregorianCalendar);
	return now;
}
 
开发者ID:Discovery-Research-Network-SCCM,项目名称:FHIR-CQL-ODM-service,代码行数:9,代码来源:FhirService.java

示例2: convert2XMLCalendar

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
public static XMLGregorianCalendar convert2XMLCalendar(Calendar calendar) {
    try {
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        return dtf.newXMLGregorianCalendar(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH) + 1,
                calendar.get(Calendar.DAY_OF_MONTH),
                calendar.get(Calendar.HOUR),
                calendar.get(Calendar.MINUTE),
                calendar.get(Calendar.SECOND),
                calendar.get(Calendar.MILLISECOND),
                calendar.get(Calendar.ZONE_OFFSET) / (1000 * 60));

    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:autumnkuang,项目名称:nenlvse1.0,代码行数:19,代码来源:DateUtil.java

示例3: newXMLGregorianCalendarSystemTime

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
/**
 * 
 * @return An object of type XMLGregorianCalendar containing the current
 *         system time and date
 * @throws DatatypeConfigurationException
 *             If the instantiation of the DatatypeFactory fails
 */
public static XMLGregorianCalendar newXMLGregorianCalendarSystemTime()
        throws DatatypeConfigurationException {
    GregorianCalendar gregorianCalendar = new GregorianCalendar();
    DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
    XMLGregorianCalendar now = datatypeFactory
            .newXMLGregorianCalendar(gregorianCalendar);
    return now;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:16,代码来源:GregorianCalendars.java

示例4: main

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
/**
 * main method.
 *
 * @param args Standard args.
 */
public static void main(String[] args) {
    try {
        String dateTimeString = "2006-11-22T00:00:00.0+01:02";
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar( dateTimeString );
        System.out.println( "XMLGregCal:" + cal.toString() );
        System.out.println( "GregCal:" + cal.toGregorianCalendar() );
        String toGCal = cal.toGregorianCalendar().toString();
        if (toGCal.indexOf("GMT+12:00") > -1) {
            throw new RuntimeException("Expected GMT+01:02");
        }
    } catch (DatatypeConfigurationException ex) {
        throw new RuntimeException(ex.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:CalendarDuration1243Test.java

示例5: main

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
/**
 * main method.
 *
 * @param args Standard args.
 */
public static void main(String[] args) {
    try {
        String dateTimeString = "0001-01-01T00:00:00.0000000-05:00";
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar( dateTimeString );
        System.out.println( "Expected: 0001-01-01T00:00:00.0000000-05:00");
        System.out.println( "Actual:" + cal.toString() );
        System.out.println( "toXMLFormat:" + cal.toXMLFormat() );
        String test = cal.toString();
        if (test.indexOf("E-7") > -1) {
            throw new RuntimeException("Expected: 0001-01-01T00:00:00.0000000-05:00");
        }
    } catch (DatatypeConfigurationException ex) {
        throw new RuntimeException(ex.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:CalendarDuration1097Test.java

示例6: giveMeCalendarForNow

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
/**
 * To get a XMLGregorianCalendar for now
 * @return a XMLGregorianCalendar for now
 * @throws DatatypeConfigurationException if it can't create a calendar
 */
public static XMLGregorianCalendar giveMeCalendarForNow() throws DatatypeConfigurationException {
  GregorianCalendar gregorianCalendar = new GregorianCalendar();
  gregorianCalendar.setTime(new Date());

  XMLGregorianCalendar result = null;
  DatatypeFactory factory = DatatypeFactory.newInstance();
  result = factory.newXMLGregorianCalendar(
          gregorianCalendar.get(GregorianCalendar.YEAR),
          gregorianCalendar.get(GregorianCalendar.MONTH) + 1,
          gregorianCalendar.get(GregorianCalendar.DAY_OF_MONTH),
          gregorianCalendar.get(GregorianCalendar.HOUR_OF_DAY),
          gregorianCalendar.get(GregorianCalendar.MINUTE),
          gregorianCalendar.get(GregorianCalendar.SECOND),
          gregorianCalendar.get(GregorianCalendar.MILLISECOND), 0);
  return result;
}
 
开发者ID:ONSdigital,项目名称:rm-common-service,代码行数:22,代码来源:DateTimeUtil.java

示例7: getXMLGregorianCalendar

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
public static XMLGregorianCalendar getXMLGregorianCalendar(Date date) {
	if (date == null) {
		return null;
	}
	// Calendar calendar = Calendar.getInstance();
	// calendar.setTimeInMillis(date.getTime());
	DatatypeFactory datatypeFactory;
	try {
		datatypeFactory = DatatypeFactory.newInstance();
	} catch (DatatypeConfigurationException e) {
		throw new RuntimeException("Failed to create XMLGregorianCalendar: " + e, e);
	}
	GregorianCalendar c = new GregorianCalendar();
	c.setTime(date);
	return datatypeFactory.newXMLGregorianCalendar(c);
	//
	// XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar();
	// xmlGregorianCalendar.setYear(calendar.get(Calendar.YEAR));
	// xmlGregorianCalendar.setMonth(calendar.get(Calendar.MONTH) + 1);
	// xmlGregorianCalendar.setDay(calendar.get(Calendar.DAY_OF_MONTH));
	// xmlGregorianCalendar.setHour(calendar.get(Calendar.HOUR_OF_DAY));
	// xmlGregorianCalendar.setMinute(calendar.get(Calendar.MINUTE));
	// xmlGregorianCalendar.setSecond(calendar.get(Calendar.SECOND));
	// xmlGregorianCalendar.setMillisecond(calendar.get(Calendar.MILLISECOND));
	// //
	// xmlGregorianCalendar.setTimezone(calendar.get(((Calendar.DST_OFFSET)+calendar.get(Calendar.ZONE_OFFSET))/(60*1000)));
	// return xmlGregorianCalendar;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:29,代码来源:XMLTools.java

示例8: applyOutages

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
public AppliedOutages applyOutages(Calendar calendar, boolean assumeConnected) {
	appliedOutages = ModelParser.applyOutages(calendar, rdfModel, assumeConnected);
	GregorianCalendar gregorianCalendar = new GregorianCalendar();
	gregorianCalendar.setTime(appliedOutages.getEffectiveEnd().getTime());
	try {
		DatatypeFactory factory = DatatypeFactory.newInstance();
		endDate = factory.newXMLGregorianCalendar(gregorianCalendar);
		Duration oneSecond = factory.newDuration("PT1S");
		endDate.add(oneSecond);
	} catch (DatatypeConfigurationException e) {
		// do nothing
	}
	return appliedOutages;
}
 
开发者ID:OmniPrise,项目名称:cim-processor,代码行数:15,代码来源:ModelParser.java

示例9: getXMLCalendar

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
/**
 * <pre>
 * 描述:日期转XMLGregorianCalendar
 * 作者:ZhangYi
 * 时间:2016年5月5日 下午4:13:36
 * 参数:(参数列表)
 * @param date	日期
 * @return
 * </pre>
 */
public static XMLGregorianCalendar getXMLCalendar(Date date) {
	DatatypeFactory datatypeFactory = null;
	try {
		datatypeFactory = DatatypeFactory.newInstance();
	} catch (DatatypeConfigurationException e) {
		logger.error("获取时间转换工厂时发生错误", e);
	}
	GregorianCalendar calendar = new GregorianCalendar();
	calendar.setTime(date);
	XMLGregorianCalendar datetime = datatypeFactory.newXMLGregorianCalendar(calendar);
	return datetime;
}
 
开发者ID:dev-share,项目名称:css-elasticsearch,代码行数:23,代码来源:DateUtil.java

示例10: getCurrentDateTime

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
private XMLGregorianCalendar getCurrentDateTime() {
  GregorianCalendar gc = new GregorianCalendar();
  DatatypeFactory dtf = null;
  try {
    dtf = DatatypeFactory.newInstance();
  } catch (DatatypeConfigurationException ex) {
    ex.printStackTrace();
  }
  return dtf.newXMLGregorianCalendar(gc);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:11,代码来源:Rdf4jValueBackendTest.java

示例11: getXMLCalendar

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
/**
 * <pre>
 * 描述:日期转XMLGregorianCalendar
 * 作者:ZhangYi
 * 时间:2016年5月5日 下午4:13:36
 * 参数:(参数列表)
 * @param date
 * @return
 * </pre>
 */
public static XMLGregorianCalendar getXMLCalendar(Date date) {
	DatatypeFactory datatypeFactory = null;
	try {
		datatypeFactory = DatatypeFactory.newInstance();
	} catch (DatatypeConfigurationException e) {
		logger.error("获取时间转换工厂时发生错误", e);
	}
	GregorianCalendar calendar = new GregorianCalendar();
	calendar.setTime(date);
	XMLGregorianCalendar datetime = datatypeFactory.newXMLGregorianCalendar(calendar);
	return datetime;
}
 
开发者ID:dev-share,项目名称:database-transform-tool,代码行数:23,代码来源:DateUtil.java

示例12: createTestFile

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
/**
 * Create test files
 *
 * @param javaVersion JDK version
 */
public void createTestFile(String javaVersion) {
    try {
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        XMLGregorianCalendar c = dtf.newXMLGregorianCalendar(EXPECTED_CAL);
        Duration d = dtf.newDuration(EXPECTED_DURATION);
        toFile((Serializable) c, filePath + javaVersion + FILENAME_CAL);
        toFile((Serializable) d, filePath + javaVersion + FILENAME_DURATION);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:SerializationTest.java

示例13: testToString

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
@Test
public void testToString() {
    try {
        String inputDateTime = "2006-10-23T22:15:01.000000135+08:00";
        DatatypeFactory factory = DatatypeFactory.newInstance();
        XMLGregorianCalendar calendar = factory.newXMLGregorianCalendar(inputDateTime);
        String toStr = calendar.toString();
        Assert.assertTrue(toStr.indexOf("E") == -1, "String value cannot contain exponent");
    } catch (DatatypeConfigurationException dce) {
        dce.printStackTrace();
        Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:XMLGregorianCalendarTest.java

示例14: test

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
@Test
public void test() throws DatatypeConfigurationException {
    DatatypeFactory dtf = DatatypeFactory.newInstance();
    XMLGregorianCalendar c1 = dtf.newXMLGregorianCalendar("1999-12-31T24:00:00");
    XMLGregorianCalendar c2 = dtf.newXMLGregorianCalendar("2000-01-01T00:00:00");
    System.out.println("c1: " + c1.getYear() + "-" + c1.getMonth() + "-" + c1.getDay() + "T" + c1.getHour());
    System.out.println(c1.equals(c2) ? "pass" : "fail"); // fails
    if (!c1.equals(c2))
        Assert.fail("hour 24 needs to be treated as equal to hour 0 of the next day");
    if (c1.getYear() != 2000 && c1.getHour() != 0)
        Assert.fail("hour 24 needs to be treated as equal to hour 0 of the next day");

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:Bug6937951Test.java

示例15: generateDemographicType

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
public static DemographicsType generateDemographicType(String dob) throws DatatypeConfigurationException {
    org.indivo.xml.phr.demographics.ObjectFactory dObjFactory = new org.indivo.xml.phr.demographics.ObjectFactory();
    DemographicsType indiDemographic = dObjFactory.createDemographicsType();
    
    DatatypeFactory dataTypeFactory = DatatypeFactory.newInstance();
    Date dobDate = UtilDateUtilities.StringToDate(dob, "yyyy/MM/dd");
    GregorianCalendar dobGregorian = new GregorianCalendar();
    dobGregorian.setTime(dobDate);
    XMLGregorianCalendar dobxml = dataTypeFactory.newXMLGregorianCalendar(dobGregorian);
    indiDemographic.setDateOfBirth(dobxml);
    
    return indiDemographic;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:14,代码来源:IndivoUtil.java


注:本文中的javax.xml.datatype.DatatypeFactory.newXMLGregorianCalendar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。