本文整理匯總了Java中javax.xml.datatype.DatatypeFactory類的典型用法代碼示例。如果您正苦於以下問題:Java DatatypeFactory類的具體用法?Java DatatypeFactory怎麽用?Java DatatypeFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DatatypeFactory類屬於javax.xml.datatype包,在下文中一共展示了DatatypeFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: preparePeriod
import javax.xml.datatype.DatatypeFactory; //導入依賴的package包/類
private Period preparePeriod(long periodStartTime, long periodEndTime)
throws DatatypeConfigurationException {
Period period = new Period();
DatatypeFactory df = DatatypeFactory.newInstance();
GregorianCalendar gc = new GregorianCalendar();
// start date
period.setStartDate(BigInteger.valueOf(periodStartTime));
gc.setTimeInMillis(periodStartTime);
period.setStartDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());
// end date
period.setEndDate(BigInteger.valueOf(periodEndTime));
gc.setTimeInMillis(periodEndTime);
period.setEndDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());
return period;
}
示例2: 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;
}
示例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;
}
示例4: setup
import javax.xml.datatype.DatatypeFactory; //導入依賴的package包/類
@BeforeClass
public static void setup() throws Exception {
SharesDataRetrievalServiceLocal sharesRetrievalService = mock(SharesDataRetrievalServiceLocal.class);
BillingDataRetrievalServiceLocal billingRetrievalService = mock(BillingDataRetrievalServiceLocal.class);
brokerShareAssembler = spy(new BrokerShareResultAssembler(
sharesRetrievalService, billingRetrievalService));
// create test data
createBillingResults();
// mock service methods
mockGetBrokerData();
mockGetBrokerRevenueSharePercentage();
mockGetOrgData(NUMBER_SUPPLIERS);
mockGetOrgData(NUMBER_CUSTOMER);
mockGetSupplierKeyForSubscription();
mockGetProductHistoryData();
mockGetSubscriptionHistoryData();
mockGetBillingResults();
mockXmlSearch();
datatypeFactory = DatatypeFactory.newInstance();
}
示例5: setup
import javax.xml.datatype.DatatypeFactory; //導入依賴的package包/類
@Before
public void setup() throws Exception {
SharesDataRetrievalServiceLocal sharesRetrievalService = mock(SharesDataRetrievalServiceLocal.class);
BillingDataRetrievalServiceLocal billingRetrievalService = mock(BillingDataRetrievalServiceLocal.class);
resellerShareAssembler = spy(new ResellerShareResultAssembler(
sharesRetrievalService, billingRetrievalService));
// create test data
createBillingResults();
// mock service methods
mockGetResellerData();
mockGetResellerRevenueSharePercentage();
mockGetOrgData(NUMBER_SUPPLIERS);
mockGetOrgData(NUMBER_CUSTOMER);
mockGetSupplierKeyForSubscription();
mockGetProductHistoryData();
mockGetSubscriptionHistoryData();
mockGetBillingResults();
mockXmlSearch();
datatypeFactory = DatatypeFactory.newInstance();
}
示例6: setup
import javax.xml.datatype.DatatypeFactory; //導入依賴的package包/類
@BeforeClass
public static void setup() throws Exception {
SharesDataRetrievalServiceLocal billingRetrievalService = mock(SharesDataRetrievalServiceLocal.class);
when(
billingRetrievalService.loadOrganizationHistoryRoles(anyLong(),
anyLong())).thenReturn(
Arrays.asList(new OrganizationRole(
OrganizationRoleType.SUPPLIER)));
supplierShareAssembler = spy(new SupplierShareResultAssembler(
billingRetrievalService));
createBillingResults();
mockOrganizationData();
mockOrganizationHistoryRoles();
mockGetMarketplaceRevenueSharePercentage();
mockGetOperatorRevenueSharePercentage();
mockGetSellerRevenueSharePercentage();
mockGetProductHistoryData();
mockGetSubscriptionHistoryData();
mockGetBillingResults();
mockFindMarketplaceHistory();
mockGetOrgData(CUSTOMER);
mockXmlSearch();
datatypeFactory = DatatypeFactory.newInstance();
}
示例7: setPeriod
import javax.xml.datatype.DatatypeFactory; //導入依賴的package包/類
void setPeriod(long periodStartTime, long periodEndTime)
throws DatatypeConfigurationException {
this.periodEndTime = periodEndTime;
Period period = new Period();
DatatypeFactory df = DatatypeFactory.newInstance();
GregorianCalendar gc = new GregorianCalendar();
// start date
period.setStartDate(BigInteger.valueOf(periodStartTime));
gc.setTimeInMillis(periodStartTime);
period.setStartDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());
// end date
period.setEndDate(BigInteger.valueOf(periodEndTime));
gc.setTimeInMillis(periodEndTime);
period.setEndDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());
result.setPeriod(period);
}
示例8: setPeriod
import javax.xml.datatype.DatatypeFactory; //導入依賴的package包/類
void setPeriod(long periodStartTime, long periodEndTime)
throws DatatypeConfigurationException {
this.periodStartTime = periodStartTime;
this.periodEndTime = periodEndTime;
Period period = new Period();
DatatypeFactory df = DatatypeFactory.newInstance();
GregorianCalendar gc = new GregorianCalendar();
// start date
period.setStartDate(BigInteger.valueOf(periodStartTime));
gc.setTimeInMillis(periodStartTime);
period.setStartDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());
// end date
period.setEndDate(BigInteger.valueOf(periodEndTime));
gc.setTimeInMillis(periodEndTime);
period.setEndDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());
result.setPeriod(period);
}
示例9: preparePeriod
import javax.xml.datatype.DatatypeFactory; //導入依賴的package包/類
private Period preparePeriod(long periodStartTime, long periodEndTime)
throws DatatypeConfigurationException {
Period period = new Period();
DatatypeFactory df = DatatypeFactory.newInstance();
GregorianCalendar gc = new GregorianCalendar();
period.setStartDate(BigInteger.valueOf(periodStartTime));
gc.setTimeInMillis(periodStartTime);
period.setStartDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());
period.setEndDate(BigInteger.valueOf(periodEndTime));
gc.setTimeInMillis(periodEndTime);
period.setEndDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());
return period;
}
示例10: toXMLCalendar
import javax.xml.datatype.DatatypeFactory; //導入依賴的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;
}
示例11: getDatatypeFactory
import javax.xml.datatype.DatatypeFactory; //導入依賴的package包/類
public static DatatypeFactory getDatatypeFactory() {
ClassLoader tccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
return Thread.currentThread().getContextClassLoader();
}
});
DatatypeFactory df = DF_CACHE.get(tccl);
if (df == null) {
synchronized (DatatypeConverterImpl.class) {
df = DF_CACHE.get(tccl);
if (df == null) { // to prevent multiple initialization
try {
df = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e) {
throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e);
}
DF_CACHE.put(tccl, df);
}
}
}
return df;
}
示例12: vulStuurgegevens
import javax.xml.datatype.DatatypeFactory; //導入依賴的package包/類
private void vulStuurgegevens(final VrijBericht vrijBericht, final VrijBerichtStuurVrijBericht verzoek, final PartijCode zendendePartij)
throws DatatypeConfigurationException {
final GroepBerichtStuurgegevens stuurgegevens = objectFactory.createGroepBerichtStuurgegevens();
stuurgegevens.setCommunicatieID(UUID.randomUUID().toString());
final SysteemNaam zendendeSysteem = new SysteemNaam();
final Referentienummer referentieNummer = new Referentienummer();
final DatumTijd tijdstipVerzending = new DatumTijd();
zendendeSysteem.setValue("BRP");
referentieNummer.setValue(UUID.randomUUID().toString());
final GregorianCalendar c = new GregorianCalendar();
final XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
c.setTime(vrijBericht.getTijdstipRegistratie());
tijdstipVerzending.setValue(xmlDate);
stuurgegevens.setZendendePartij(objectFactory.createGroepBerichtStuurgegevensZendendePartij(zendendePartij));
stuurgegevens.setZendendeSysteem(objectFactory.createGroepBerichtStuurgegevensZendendeSysteem(zendendeSysteem));
stuurgegevens.setReferentienummer(objectFactory.createGroepBerichtStuurgegevensReferentienummer(referentieNummer));
stuurgegevens.setTijdstipVerzending(objectFactory.createGroepBerichtStuurgegevensTijdstipVerzending(tijdstipVerzending));
verzoek.setStuurgegevens(objectFactory.createObjecttypeBerichtStuurgegevens(stuurgegevens));
}
示例13: test
import javax.xml.datatype.DatatypeFactory; //導入依賴的package包/類
private static void test(int offsetMinutes)
throws DatatypeConfigurationException {
XMLGregorianCalendar calendar = DatatypeFactory.newInstance().
newXMLGregorianCalendar();
calendar.setTimezone(60 + offsetMinutes);
TimeZone timeZone = calendar.getTimeZone(DatatypeConstants.FIELD_UNDEFINED);
String expected = (offsetMinutes < 10 ? "GMT+01:0" : "GMT+01:")
+ offsetMinutes;
if (!timeZone.getID().equals(expected)) {
throw new RuntimeException("Test failed: expected timezone: " +
expected + " Actual: " + timeZone.getID());
}
}
示例14: 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());
}
}
示例15: 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());
}
}