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:org.kalypso.simulation.ui.calccase.ModelNature.java
private Properties createVariablesForAntLaunch(final IContainer folder) throws CoreException { final Properties attributes = new Properties(); final IProject project = folder.getProject(); final KalypsoAuthPlugin authPlugin = KalypsoAuthPlugin.getDefault(); final IKalypsoUser currentUser = authPlugin.getCurrentUser(); final Date now = new Date(); final TimeZone kalypsoTimezone = KalypsoCorePlugin.getDefault().getTimeZone(); // auf x stunden vorher runden! hngt von der Modellspec ab final Calendar cal = Calendar.getInstance(); cal.setTimeZone(kalypsoTimezone);//from ww w . j a v a2 s . c o m cal.setTime(now); attributes.setProperty("kalypso.currentTime", DatatypeConverter.printDateTime(cal)); //$NON-NLS-1$ attributes.setProperty("kalypso.timezone", kalypsoTimezone.getID()); //$NON-NLS-1$ // erstmal auf die letzte Stunde runden cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); // jetzt solange ganze stunden abziehen, bis der Wert ins // Zeitvalidierungsschema passt int count = 0; while (!validateTime(cal)) { cal.add(Calendar.HOUR_OF_DAY, -1); // nach 24h sptestens abbrechen! count++; if (count == 24) throw new CoreException(new Status(IStatus.ERROR, KalypsoSimulationUIPlugin.getID(), Messages.getString("org.kalypso.simulation.ui.calccase.ModelNature.7") + cal)); //$NON-NLS-1$ } attributes.setProperty("kalypso.startforecast", DatatypeConverter.printDateTime(cal)); //$NON-NLS-1$ // standardzeit abziehen final int simDiff = new Integer(m_metadata.getProperty(META_PROP_DEFAULT_SIMHOURS, "120")).intValue(); //$NON-NLS-1$ cal.add(Calendar.HOUR_OF_DAY, -simDiff); attributes.setProperty("kalypso.startsim", DatatypeConverter.printDateTime(cal)); //$NON-NLS-1$ attributes.setProperty("kalypso.currentUser", currentUser.getUserName()); //$NON-NLS-1$ attributes.setProperty("simulation_project_loc", project.getLocation().toPortableString()); //$NON-NLS-1$ attributes.setProperty("calc.dir", folder.getLocation().toPortableString()); //$NON-NLS-1$ attributes.setProperty("project.dir", project.getLocation().toPortableString()); //$NON-NLS-1$ attributes.setProperty("calc.path", folder.getFullPath().toPortableString()); //$NON-NLS-1$ attributes.setProperty("project.path", project.getFullPath().toPortableString()); //$NON-NLS-1$ try { attributes.setProperty("calc.url", ResourceUtilities.createURL(folder).toString()); //$NON-NLS-1$ attributes.setProperty("project.url", ResourceUtilities.createURL(project).toString()); //$NON-NLS-1$ } catch (final MalformedURLException e) { // should never happen e.printStackTrace(); } catch (final URIException e) { // TODO Auto-generated catch block e.printStackTrace(); } return attributes; }
From source file:org.mule.el.context.ServerContextTestCase.java
@Test public void dateTimeToString() { assertEquals(DatatypeConverter.printDateTime(Calendar.getInstance()).substring(0, 18), ((String) evaluate("server.dateTime").toString()).substring(0, 18)); }
From source file:org.openestate.io.daft_ie.DaftIeUtils.java
public static String printDateTime(Calendar value) { if (value == null) throw new IllegalArgumentException("Can't print date-time value!"); else/*from w ww.j a va 2s.c o m*/ return DatatypeConverter.printDateTime(value); }
From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java
public static String printDateUpdatedType(Calendar value) { if (value == null || !isValidDateUpdatedType(value)) throw new IllegalArgumentException("Can't print date-updated value!"); else/* w w w . j a v a2 s . c o m*/ return DatatypeConverter.printDateTime(value); }
From source file:org.paxml.el.UtilFunctions.java
/** * Print date/time into xml format./*from ww w . ja v a 2s. c om*/ * * @param cal * the calendar or date that represents the datetime. If null * given, it will take the current system time. * @param includeTime * true to include time part, false exclude time part * @return the xml standard date/time string */ public static String printXmlDateTime(Object cal, boolean includeTime) { Calendar c = null; if (cal == null) { c = new GregorianCalendar(); } else if (cal instanceof Calendar) { c = (Calendar) cal; } else if (cal instanceof Date) { c = new GregorianCalendar(); c.setTime((Date) cal); } else { throw new PaxmlRuntimeException( "Unsupported date time of type " + cal.getClass().getName() + ": " + cal); } return includeTime ? DatatypeConverter.printDateTime(c) : DatatypeConverter.printDate(c); }
From source file:org.renci.ahab.ndllib.transport.OrcaSMXMLRPCProxy.java
/** submit an ndl request to create a slice, using explicitly specified users array * * @param sliceId/*from w w w . j av a 2s . c o m*/ * @param resReq * @param users * @return */ @SuppressWarnings("unchecked") public Boolean renewSlice(String sliceId, Date newDate) throws Exception { assert (sliceId != null); Boolean result = false; setSSLIdentity(); Map<String, Object> rr = null; try { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); //TODO //config.setServerURL(new URL(GUI.getInstance().getSelectedController())); config.setServerURL(new URL(CONTROLLER_URL)); //TODO XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); // set this transport factory for host-specific SSLContexts to work XmlRpcCommonsTransportFactory f = new XmlRpcCommonsTransportFactory(client); client.setTransportFactory(f); // create sliver Calendar ecal = Calendar.getInstance(); ecal.setTime(newDate); String endDateString = DatatypeConverter.printDateTime(ecal); // RFC3339/ISO8601 rr = (Map<String, Object>) client.execute(RENEW_SLICE, new Object[] { sliceId, new Object[] {}, endDateString }); } catch (MalformedURLException e) { //TODO //throw new Exception("Please check the SM URL " + GUI.getInstance().getSelectedController()); throw new Exception("Please check the SM URL " + CONTROLLER_URL); //TODO } catch (XmlRpcException e) { //TODO //throw new Exception("Unable to contact SM " + GUI.getInstance().getSelectedController() + " due to " + e); throw new Exception("Unable to contact SM " + CONTROLLER_URL + " due to " + e); //TODO } catch (Exception e) { //TODO //throw new Exception("Unable to contact SM " + GUI.getInstance().getSelectedController()); throw new Exception("Unable to contact SM " + CONTROLLER_URL); //TODO } if (rr == null) //TODO //throw new Exception("Unable to contact SM " + GUI.getInstance().getSelectedController()); throw new Exception("Unable to contact SM " + CONTROLLER_URL); //TODO if ((Boolean) rr.get(ERR_RET_FIELD)) throw new Exception("Unable to renew slice: " + (String) rr.get(MSG_RET_FIELD)); result = (Boolean) rr.get(RET_RET_FIELD); return result; }