List of usage examples for javax.xml.bind DatatypeConverter printDateTime
public static String printDateTime(java.util.Calendar val)
Converts a Calendar value into a string.
From source file:Main.java
/** * Converts Date into XML-Tag with type xsd:dateTime */// w ww . ja v a2s . co m public static String getXMLDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return DatatypeConverter.printDateTime(calendar); }
From source file:Main.java
/** * Converts Date into XML-Tag with type xsd:dateTime *//*from w w w . j av a2 s.co m*/ public static String getXMLDate(final Date date) { final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return DatatypeConverter.printDateTime(calendar); }
From source file:Main.java
public static String getDateTimeString(Date dateTime) { Calendar cal = Calendar.getInstance(); if (dateTime != null) { cal.setTime(dateTime);//from ww w . jav a 2 s . co m } return DatatypeConverter.printDateTime(cal); }
From source file:Main.java
/** * Convert a BPMN variable value to a XSL parameter value * // w w w .j a va 2s .co m * @param bpmnVariableValue * A BPMN variable value * @return The XSL parameter value */ public static String convertBpmnVariableValueToXslParam(final Object bpmnVariableValue) { final String xslParamValue; if (bpmnVariableValue != null) { if (bpmnVariableValue instanceof Date) { final Calendar calendar = Calendar.getInstance(); calendar.setTime((Date) bpmnVariableValue); xslParamValue = DatatypeConverter.printDateTime(calendar); } else { xslParamValue = bpmnVariableValue.toString(); } } else { xslParamValue = ""; } return xslParamValue; }
From source file:Main.java
/** * Formats a date value in a string, assuming UTC timezone and Canada locale. * This method should be used only for occasional formatting. * * @param date The date to format, or {@code null}. * @return The formatted date, or {@code null} if the given date was null. * * @see DatatypeConverter#printDateTime(Calendar) * * @since 3.06//from w ww. j a va 2 s . c om */ public static String printDateTime(final Date date) { if (date == null) { return null; } final Calendar calendar = CALENDAR.get(); calendar.setTime(date); return DatatypeConverter.printDateTime(calendar); }
From source file:com.mpobjects.rtcalltree.report.xml.XmlGenerator.java
/** * Start the report element//from w w w.j a v a 2s.c o m * * @param aCreationDate * @throws XMLStreamException */ public void startReport(Date aCreationDate) throws XMLStreamException { writer.writeStartDocument(); writer.setDefaultNamespace(NAMESPACE); writer.writeStartElement(NAMESPACE, "report"); writer.writeDefaultNamespace(NAMESPACE); writer.writeAttribute("version", VERSION); calendar.setTime(aCreationDate); writer.writeAttribute("timestamp", DatatypeConverter.printDateTime(calendar)); }
From source file:com.mpobjects.rtcalltree.report.xml.XmlGenerator.java
protected void writeCallTreeEntry(CalltreeEntry aEntry) throws XMLStreamException { writer.writeAttribute("depth", Integer.toString(aEntry.getDepth())); if (aEntry.getTimestamp() > -1) { calendar.setTimeInMillis(aEntry.getTimestamp()); writer.writeAttribute("start-time", DatatypeConverter.printDateTime(calendar)); }//from w w w . j ava 2 s . c o m writer.writeAttribute("duration", Long.toString(aEntry.getDeltaTime())); writer.writeAttribute("class", aEntry.getClassName()); writer.writeAttribute("method", aEntry.getMethodName()); if (!StringUtils.isEmpty(aEntry.getSourceFilename())) { writer.writeAttribute("source-file", aEntry.getSourceFilename()); writer.writeAttribute("source-line", Integer.toString(aEntry.getSourceLine())); } writeParameterElements(aEntry); }
From source file:com.kappaware.logtrawler.Utils.java
public static String printIsoDateTime(Long ts) { if (ts != null) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(ts);// w w w.ja v a2 s . c om return DatatypeConverter.printDateTime(c); } else { return null; } }
From source file:cz.cas.lib.proarc.common.export.cejsh.CejshBuilderTest.java
@Test public void testWriteProperties() throws Exception { CejshBuilder cb = new CejshBuilder(new CejshConfig()); File folder = temp.getRoot(); int articleCount = 3; cb.writeProperties(folder, articleCount); File file = new File(folder, CejshBuilder.IMPORT_PROPERTIES_FILENAME); assertTrue(file.exists());/*from ww w .j a v a 2 s . co m*/ Properties props = new Properties(); props.load(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8)); assertEquals(String.valueOf(articleCount), props.getProperty(CejshBuilder.PROP_IMPORT_OBJECTS)); assertEquals("1", props.getProperty(CejshBuilder.PROP_IMPORT_BWMETA_FILES)); assertEquals("0", props.getProperty(CejshBuilder.PROP_IMPORT_CONTENT_FILES)); String resultDate = props.getProperty(CejshBuilder.PROP_IMPORT_INFODATE); assertNotNull(resultDate); String expDated = DatatypeConverter.printDateTime(new GregorianCalendar(CejshBuilder.UTC)).substring(0, 14); assertEquals(resultDate, expDated, resultDate.substring(0, 14)); }
From source file:org.metaservice.frontend.rest.SparqlEndpointResource.java
public @NotNull String dateToLiteral(@NotNull Calendar date) { return "\"" + DatatypeConverter.printDateTime(date) + "\"^^xsd:dateTime"; }