List of usage examples for javax.xml.datatype XMLGregorianCalendar toGregorianCalendar
public abstract GregorianCalendar toGregorianCalendar();
From source file:com.evolveum.midpoint.web.component.prism.ContainerWrapper.java
private static String formatTime(XMLGregorianCalendar time) { DateFormat formatter = DateFormat.getDateInstance(); return formatter.format(time.toGregorianCalendar().getTime()); }
From source file:eu.europa.esig.dss.DSSXMLUtils.java
/** * This method allows to convert the given text (XML representation of a date) to the {@code Date}. * * @param text the text representing the XML date * @return {@code Date} converted or null */// w ww.j a v a2s. com public static Date getDate(final String text) { try { final DatatypeFactory datatypeFactory = DatatypeFactory.newInstance(); final XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(text); return xmlGregorianCalendar.toGregorianCalendar().getTime(); } catch (DatatypeConfigurationException e) { // do nothing } return null; }
From source file:py.una.pol.karaku.services.util.ServiceUtil.java
/** * Converts an XMLGregorianCalendar to an instance of java.util.Date * /*from ww w . j av a2 s . co m*/ * @param xgc * Instance of {@link XMLGregorianCalendar} or a null reference * @return {@link Date} instance whose value is based upon the value in the * xgc parameter. If the xgc parameter is null then this method will * simply return null. */ public Date asDate(XMLGregorianCalendar xgc) { if (xgc == null) { return null; } return xgc.toGregorianCalendar().getTime(); }
From source file:fi.vrk.xroad.catalog.lister.JaxbConverter.java
public LocalDateTime toLocalDateTime(XMLGregorianCalendar calendar) { return calendar.toGregorianCalendar().toZonedDateTime().toLocalDateTime(); }
From source file:dk.nsi.minlog.ws.ws.MinlogudtraekserviceImpl.java
/** * Convert to DateTime or null if xmlDate is null. * //from w w w.j a v a2 s . c o m * @param xmlDate * @return A datetime from the xmlDate. */ private DateTime nullableDateTime(XMLGregorianCalendar xmlDate) { return xmlDate != null ? new DateTime(xmlDate.toGregorianCalendar()) : null; }
From source file:ee.ria.xroad.common.conf.globalconf.ConfigurationAnchor.java
/** * @return the generated at date// w ww . j a v a2 s.co m */ public Date getGeneratedAt() { XMLGregorianCalendar generatedAt = confType.getGeneratedAt(); if (generatedAt == null) { return null; } return generatedAt.toGregorianCalendar().getTime(); }
From source file:org.killbill.billing.plugin.adyen.dao.TestAdyenDao.java
@Test(groups = "slow") public void testInsertNotification() throws SQLException, IOException { final NotificationRequestItem notificationRequestItem = new NotificationRequestItem(); final Amount amount = new Amount(); amount.setValue(12L);/* ww w . ja va2 s .c o m*/ amount.setCurrency("EUR"); notificationRequestItem.setAmount(amount); notificationRequestItem.setEventCode(UUID.randomUUID().toString()); final XMLGregorianCalendar calendar = Mockito.mock(XMLGregorianCalendar.class); Mockito.when(calendar.toGregorianCalendar()).thenReturn(new GregorianCalendar()); notificationRequestItem.setEventDate(calendar); notificationRequestItem.setMerchantAccountCode(UUID.randomUUID().toString()); notificationRequestItem.setMerchantReference(UUID.randomUUID().toString()); final ArrayOfString operations = new ArrayOfString(); operations.getString().add(UUID.randomUUID().toString()); notificationRequestItem.setOperations(operations); notificationRequestItem.setOriginalReference(UUID.randomUUID().toString()); notificationRequestItem.setPaymentMethod(UUID.randomUUID().toString()); notificationRequestItem.setPspReference(UUID.randomUUID().toString()); notificationRequestItem.setReason(UUID.randomUUID().toString()); notificationRequestItem.setSuccess(true); final NotificationItem notificationItem = new NotificationItem(notificationRequestItem); final UUID kbAccountId = UUID.randomUUID(); final UUID kbPaymentId = UUID.randomUUID(); final UUID kbPaymentTransactionId = UUID.randomUUID(); final TransactionType transactionType = TransactionType.AUTHORIZE; final DateTime dateTime = new DateTime(DateTimeZone.UTC); final UUID kbTenantId = UUID.randomUUID(); dao.addNotification(kbAccountId, kbPaymentId, kbPaymentTransactionId, transactionType, notificationItem, dateTime, kbTenantId); final AdyenNotificationsRecord record = dao.getNotification(notificationRequestItem.getPspReference()); Assert.assertNotNull(record.getRecordId()); Assert.assertEquals(record.getKbAccountId(), kbAccountId.toString()); Assert.assertEquals(record.getKbPaymentId(), kbPaymentId.toString()); Assert.assertEquals(record.getKbPaymentTransactionId(), kbPaymentTransactionId.toString()); Assert.assertEquals(record.getTransactionType(), transactionType.toString()); Assert.assertEquals(record.getAmount().compareTo(new BigDecimal("12")), 0); Assert.assertEquals(record.getCurrency(), "EUR"); Assert.assertEquals(record.getEventCode(), notificationItem.getEventCode()); Assert.assertEquals(record.getMerchantAccountCode(), notificationItem.getMerchantAccountCode()); Assert.assertEquals(record.getMerchantReference(), notificationItem.getMerchantReference()); Assert.assertEquals(record.getOperations(), operations.getString().get(0)); Assert.assertEquals(record.getOriginalReference(), notificationItem.getOriginalReference()); Assert.assertEquals(record.getPaymentMethod(), notificationItem.getPaymentMethod()); Assert.assertEquals(record.getPspReference(), notificationItem.getPspReference()); Assert.assertEquals(record.getReason(), notificationItem.getReason()); Assert.assertTrue(record.getSuccess() == '1'); Assert.assertEquals(new DateTime(record.getCreatedDate(), DateTimeZone.UTC) .compareTo(DefaultClock.truncateMs(dateTime)), 0); Assert.assertEquals(record.getKbTenantId(), kbTenantId.toString()); }
From source file:be.fedict.eid.pkira.portal.util.TypeMapper.java
public Date map(XMLGregorianCalendar xmlGregorianCalendar) { if (xmlGregorianCalendar == null) { return null; } else {/*from w w w. j av a 2 s . co m*/ return xmlGregorianCalendar.toGregorianCalendar().getTime(); } }
From source file:arxiv.xml.XMLParser.java
/** * Parse the response date. The result will be in UTC. *//* w ww . j a v a 2s. c om*/ private ZonedDateTime parseResponseDate(XMLGregorianCalendar xmlGregorianCalendar) { return xmlGregorianCalendar.toGregorianCalendar().toZonedDateTime().withZoneSameInstant(ZoneOffset.UTC); }
From source file:io.github.mikesaelim.arxivoaiharvester.xml.XMLParser.java
/** * Parse the response date. The result will be in UTC. *//* ww w . j av a 2 s . co m*/ @VisibleForTesting ZonedDateTime parseResponseDate(XMLGregorianCalendar xmlGregorianCalendar) { return xmlGregorianCalendar.toGregorianCalendar().toZonedDateTime().withZoneSameInstant(ZoneOffset.UTC); }