List of usage examples for java.text DateFormat getDateTimeInstance
public static final DateFormat getDateTimeInstance()
From source file:org.apache.cocoon.generation.StatusGenerator.java
/** * Generate the main status document.//from www . j ava 2s.c o m */ private void genStatus() throws SAXException, ProcessingException { // Root element. // The current date and time. String dateTime = DateFormat.getDateTimeInstance().format(new Date()); String localHost; // The local host. try { localHost = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { getLogger().debug("StatusGenerator:UnknownHost", e); localHost = ""; } catch (SecurityException e) { getLogger().debug("StatusGenerator:Security", e); localHost = ""; } AttributesImpl atts = new AttributesImpl(); atts.addCDATAAttribute(NAMESPACE, "date", dateTime); atts.addCDATAAttribute(NAMESPACE, "host", localHost); atts.addCDATAAttribute(NAMESPACE, "cocoon-version", Constants.VERSION); super.contentHandler.startElement(NAMESPACE, "statusinfo", "statusinfo", atts); genVMStatus(); genProperties(); if (this.showLibrary) { genLibrarylist(); } // End root element. super.contentHandler.endElement(NAMESPACE, "statusinfo", "statusinfo"); }
From source file:com.nuxeo.intranet.jenkins.web.JenkinsJobsFetcher.java
@SuppressWarnings("boxing") protected String computeLastUpdateFeedbackMessage(JenkinsJsonConverter converter) { StringBuilder res = new StringBuilder(); res.append("Last Update done at "); DateFormat aDateFormat = DateFormat.getDateTimeInstance(); res.append(aDateFormat.format((new Date()))); res.append('\n'); // copy error messages that could have been notified to JSF List<FacesMessage> messages = facesMessages.getCurrentMessagesForControl(feedbackComponentId); if (messages != null) { for (FacesMessage msg : messages) { if (msg.getSeverity().getOrdinal() > 0) { res.append(msg.getSummary()); res.append('\n'); } else { res.append("to remove: " + msg.getSummary()); res.append('\n'); }/*from w w w. j a v a2 s. c om*/ } } // add final message if (converter != null) { res.append(String.format("Jobs retrieved from Jenkins: %s new failures, %s fixed, %s unchanged.", converter.getNewFailingCount(), converter.getFixedCount(), converter.getUnchangedCount())); } return res.toString(); }
From source file:de.codesourcery.eve.skills.ui.components.impl.planning.CalendarEntryEditorComponent.java
private String format(Date date) { return DateFormat.getDateTimeInstance().format(date); }
From source file:net.unicon.sakora.impl.csv.CsvCommonHandlerService.java
public synchronized void completeRun(boolean success) { // run this after a run completes String runId = getCurrentSyncRunId(); Date start = (Date) syncVars.get(SYNC_VAR_STARTDATE); log.info("SakoraCSV sync complete (" + (success ? "success" : "FAILED") + ") for run (" + runId + ") started on " + DateFormat.getDateTimeInstance().format(start)); syncVars.put(SYNC_VAR_STATUS, success ? SYNC_STATE_COMPLETE : SYNC_STATE_FAILED); if (success) { StringBuilder sb = new StringBuilder(); int total_lines = 0; int total_errors = 0; int total_adds = 0; int total_updates = 0; int total_deletes = 0; int total_seconds = 0; // compile and output the stats data to the logs @SuppressWarnings("unchecked") Map<String, Map<String, Integer>> stats = getCurrentSyncVar(SYNC_VAR_HANDLER_STATS, Map.class); for (Map.Entry<String, Map<String, Integer>> entry : stats.entrySet()) { String handler = entry.getKey(); Map<String, Integer> handlerStats = entry.getValue(); int lines = handlerStats.get("lines"); int errors = handlerStats.get("errors"); int adds = handlerStats.get("adds"); int updates = handlerStats.get("updates"); int deletes = handlerStats.get("deletes"); int seconds = handlerStats.get("seconds"); total_lines += lines;/*from w ww . ja v a 2 s . c o m*/ total_errors += errors; total_adds += adds; total_updates += updates; total_deletes += deletes; total_seconds += seconds; sb.append(" - "); sb.append(StringUtils.rightPad(handler, 20)); sb.append(": processed "); sb.append(String.format("%6d", lines)); sb.append(" lines with "); sb.append(String.format("%4d", errors)); sb.append(" errors in "); sb.append(String.format("%4d", seconds)); sb.append(" seconds: "); sb.append(String.format("%4d", adds)); sb.append(" adds, "); sb.append(String.format("%4d", updates)); sb.append(" updates, "); sb.append(String.format("%4d", deletes)); sb.append(" deletes\n"); } // total summary (start, end, totals) sb.append(" --- TOTAL: processed "); sb.append(String.format("%6d", total_lines)); sb.append(" lines with "); sb.append(String.format("%5d", total_errors)); sb.append(" errors in "); sb.append(String.format("%5d", total_seconds)); sb.append(" seconds: "); sb.append(String.format("%5d", total_adds)); sb.append(" adds, "); sb.append(String.format("%5d", total_updates)); sb.append(" updates, "); sb.append(String.format("%5d", total_deletes)); sb.append(" deletes\n"); syncVars.put(SYNC_VAR_SUMMARY, sb.toString()); log.info("SakoraCSV sync statistics for run (" + runId + "):\n" + sb.toString()); } }
From source file:com.hypersocket.i18n.I18N.java
private static Object[] formatParameters(Object... arguments) { Collection<Object> formatted = new ArrayList<Object>(arguments.length); for (Object arg : arguments) { if (arg instanceof Date) { formatted.add(DateFormat.getDateTimeInstance().format(arg)); } else {//from w w w . j a v a 2 s. c o m formatted.add(arg); } } return formatted.toArray(new Object[formatted.size()]); }
From source file:com.clustercontrol.jmx.factory.RunMonitorJmx.java
/** * JMX ??//from w ww .j ava 2 s . c om * * @param facilityId ID * @return ???????true */ @Override public boolean collect(String facilityId) { boolean result = false; if (m_now != null) { m_nodeDate = m_now.getTime(); } m_value = 0; exception = null; NodeInfo node = null; if (!m_isMonitorJob) { node = nodeInfo.get(facilityId); } else { try { // ?? node = new RepositoryControllerBean().getNode(facilityId); } catch (Exception e) { m_message = MessageConstant.MESSAGE_COULD_NOT_GET_NODE_ATTRIBUTES.getMessage(); return false; } } JMXServiceURL url = null; try { String rmiFormat = HinemosPropertyUtil.getHinemosPropertyStr("monitor.jmx.rmi.format", "service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi"); String urlStr = String.format(rmiFormat, node.getAvailableIpAddress(), jmx.getPort()); m_log.debug("facilityId=" + facilityId + ", url=" + urlStr); url = new JMXServiceURL(urlStr); } catch (Exception e) { m_log.warn("fail to initialize JMXServiceURL : " + e.getMessage() + " (" + e.getClass().getName() + ")", e); exception = e; return result; } JMXConnector jmxc = null; try { Map<String, Object> env = new HashMap<>(); if (jmx.getAuthUser() != null) env.put(JMXConnector.CREDENTIALS, new String[] { jmx.getAuthUser(), jmx.getAuthPassword() }); System.setProperty("sun.rmi.transport.tcp.responseTimeout", Integer.toString(HinemosPropertyUtil .getHinemosPropertyNum("system.sun.rmi.transport.tcp.responseTimeout", Long.valueOf(10 * 1000)) .intValue())); jmxc = JMXConnectorFactory.connect(url, env); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); JmxMasterInfo jmxMasterInfo = QueryUtil.getJmxMasterInfoPK(jmx.getMasterId()); Object value = mbsc.getAttribute(new ObjectName(jmxMasterInfo.getObjectName()), jmxMasterInfo.getAttributeName()); m_value = Double.parseDouble( searchTargetValue(value, Arrays.asList(KeyParser.parseKeys(jmxMasterInfo.getKeys()))) .toString()); // ?? if (m_convertFlg == ConvertValueConstant.TYPE_DELTA) { // ?? MonitorJmxValue valueEntity = null; Double prevValue = 0d; Long prevDate = 0l; if (!m_isMonitorJob) { // ?? // cache?? valueEntity = MonitorJmxCache.getMonitorJmxValue(m_monitorId, facilityId); // ??? prevValue = valueEntity.getValue(); if (valueEntity.getGetDate() != null) { prevDate = valueEntity.getGetDate(); } } else { // ?? valueEntity = new MonitorJmxValue(new MonitorJmxValuePK(m_monitorId, facilityId)); if (m_prvData instanceof MonitorJmxValue) { // ???? prevValue = ((MonitorJmxValue) m_prvData).getValue(); prevDate = ((MonitorJmxValue) m_prvData).getGetDate(); } } // JMX???? valueEntity.setValue(Double.valueOf(m_value)); valueEntity.setGetDate(m_nodeDate); if (!m_isMonitorJob) { // ???ID????? if (m_monitor.getMonitorFlg()) MonitorJmxCache.update(m_monitorId, facilityId, valueEntity); int m_validSecond = HinemosPropertyUtil .getHinemosPropertyNum("monitor.jmx.valid.second", Long.valueOf(15)).intValue(); // ??????????? int tolerance = (m_runInterval + m_validSecond) * 1000; if (prevDate > m_nodeDate - tolerance) { // ??null??? if (prevValue == null) { m_log.debug("collect() : prevValue is null"); m_prevNullchk = true; return false; } m_value = m_value - prevValue; } else { if (prevDate != 0l) { DateFormat df = DateFormat.getDateTimeInstance(); df.setTimeZone(HinemosTime.getTimeZone()); String[] args = { df.format(new Date(prevDate)) }; m_message = MessageConstant.MESSAGE_TOO_OLD_TO_CALCULATE.getMessage(args); return false; } else { // ???0?? m_nodeDate = 0l; } } } else { m_value = m_value - prevValue; m_curData = valueEntity; } } m_log.debug(jmxMasterInfo.getName() + " : " + m_value + " " + jmxMasterInfo.getMeasure()); result = true; } catch (NumberFormatException e) { m_log.info("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); String[] args = { Double.toString(m_value) }; m_message = MessageConstant.MESSAGE_COULD_NOT_GET_NUMERIC_VALUE.getMessage(args); return false; } catch (Exception e) { String message = e.getMessage(); if (message != null) { message = message.replaceAll("\n", ""); } m_log.warn("fail to access JMXService : " + message + " (" + e.getClass().getName() + ")"); exception = e; } finally { try { if (jmxc != null) { jmxc.close(); } } catch (IOException e) { m_log.info("fail to close JMXService : " + e.getMessage() + " (" + e.getClass().getName() + ")"); exception = e; } } return result; }
From source file:org.apache.myfaces.tomahawk.util.ErrorPageWriter.java
public static void debugHtml(Writer writer, FacesContext faces) throws IOException { init(faces);//from ww w . j ava2s. co m Date now = new Date(); for (int i = 0; i < DEBUG_PARTS.length; i++) { if ("message".equals(DEBUG_PARTS[i])) { writer.write(faces.getViewRoot().getViewId()); } else if ("now".equals(DEBUG_PARTS[i])) { writer.write(DateFormat.getDateTimeInstance().format(now)); } else if ("tree".equals(DEBUG_PARTS[i])) { writeComponent(writer, faces.getViewRoot(), null); } else if ("vars".equals(DEBUG_PARTS[i])) { writeVariables(writer, faces); } else { writer.write(DEBUG_PARTS[i]); } } }
From source file:cloud.artik.example.simplecontroller.ControlActivity.java
private void displayDeviceStatus(String status, String updateTimems) { mDeviceStatus.setText(status);/*from w w w. ja v a2 s. co m*/ long time_ms = Long.parseLong(updateTimems); mStatusUpdateTime.setText(DateFormat.getDateTimeInstance().format(new Date(time_ms))); }
From source file:com.rmn.qa.servlet.BmpServlet.java
/** * /*from w w w . j a v a2 s .c o m*/ * {@inheritDoc} */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); response.setStatus(200); StringBuilder builder = new StringBuilder(); builder.append("<html>"); builder.append("<head>"); builder.append("<title>BrowserMobProxy instances</title>"); builder.append("</head>"); builder.append("<body>"); builder.append("<H1>Grid Hub "); builder.append(coreVersion).append(coreRevision); builder.append("</H1>"); Map<String, ProxyHolder> proxyMap = BmpProxyRegistry.getInstance().getProxyMap(); DateFormat df = DateFormat.getDateTimeInstance(); if (proxyMap.isEmpty()) { builder.append("No BrowserMobProxy instances currently running."); } else { for (Entry<String, ProxyHolder> entry : proxyMap.entrySet()) { StringBuilder localBuilder = new StringBuilder(); ProxyHolder holder = entry.getValue(); String uuid = entry.getKey(); localBuilder.append("<fieldset>"); localBuilder.append("<legend>BrowserMobProxy for test id ").append(uuid).append("</legend>"); localBuilder.append("listening on ").append(holder.getProxy().getPort()).append("<br/>"); localBuilder.append("started at ").append(df.format(new Date(holder.getCreated()))).append("<br/>"); localBuilder.append("</fieldset>"); builder.append(localBuilder.toString()); } } try (InputStream in = new ByteArrayInputStream(builder.toString().getBytes("UTF-8"));) { ByteStreams.copy(in, response.getOutputStream()); } finally { response.flushBuffer(); } }
From source file:com.corporatetaxi.TaxiOntheWay_Activity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_taxiontheway); taxiOntheWay_activity_instance = this; AppPreferences.setApprequestTaxiScreen(TaxiOntheWay_Activity.this, true); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitleTextColor(Color.BLACK); setSupportActionBar(toolbar);/*from w w w .jav a2 s . co m*/ // getSupportActionBar().setDisplayHomeAsUpEnabled(true); String title = getString(R.string.title_activity_taxidetail); getSupportActionBar().setTitle(title); fab_menu = (FloatingActionsMenu) findViewById(R.id.fab_menu); fab_msg = (FloatingActionButton) findViewById(R.id.fab_message); fab_call = (FloatingActionButton) findViewById(R.id.fab_call); fab_cancel = (FloatingActionButton) findViewById(R.id.fab_cancel); textheader = (TextView) findViewById(R.id.textheader); textname = (TextView) findViewById(R.id.name_text); textmobilenumber = (TextView) findViewById(R.id.mobile_text); textcompanyname = (TextView) findViewById(R.id.companyname); texttaxinumber = (TextView) findViewById(R.id.taxinumber); taxiname = (TextView) findViewById(R.id.taxinametext); mtextnamehead = (TextView) findViewById(R.id.namehead); mtextcompanyhead = (TextView) findViewById(R.id.companyhead); mtextmobilehead = (TextView) findViewById(R.id.mobilehead); mtexttexinumhead = (TextView) findViewById(R.id.taxiplatthead); taxinamehead = (TextView) findViewById(R.id.taxinamehead); mdriverimage = (ImageView) findViewById(R.id.driver_image); mdriverlicense = (TextView) findViewById(R.id.driverlicense); medriverinsurance = (TextView) findViewById(R.id.driverinsurance); map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); map.setMapType(GoogleMap.MAP_TYPE_NORMAL); getLocation(); Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf"); textheader.setTypeface(tf); mtextnamehead.setTypeface(tf); mtextcompanyhead.setTypeface(tf); mtextmobilehead.setTypeface(tf); mtexttexinumhead.setTypeface(tf); textname.setTypeface(tf); textmobilenumber.setTypeface(tf); textcompanyname.setTypeface(tf); texttaxinumber.setTypeface(tf); taxinamehead.setTypeface(tf); taxiname.setTypeface(tf); mdriverlicense.setTypeface(tf); medriverinsurance.setTypeface(tf); ////////current date time////////////////// currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date()); Log.d("currentdatetime", currentDateTimeString); /////back arrow //////////// // final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha); // upArrow.setColorFilter(getResources().getColor(R.color.colorbutton), PorterDuff.Mode.SRC_ATOP); // getSupportActionBar().setHomeAsUpIndicator(upArrow); /////////////notification data/////////////// Intent intent = getIntent(); String data = intent.getStringExtra("data"); Log.d("data value", data + ""); // caceldialog(); JSONObject jsonObject = null; try { jsonObject = new JSONObject(data); AppPreferences.setAcceptdriverId(TaxiOntheWay_Activity.this, jsonObject.getString("driverId")); Log.d("driverid---", AppPreferences.getAcceptdriverId(TaxiOntheWay_Activity.this)); drivermobile = jsonObject.getString("mobile"); drivername = jsonObject.getString("username"); drivercompanyname = jsonObject.getString("taxicompany"); drivertaxiname = jsonObject.getString("vehicalname"); drivertexinumber = jsonObject.getString("vehicle_number"); // driverlatitude = jsonObject.getDouble("latitude"); // driverlongitude = jsonObject.getDouble("longitude"); driverimage = jsonObject.getString("driverImage"); SourceAddress = jsonObject.getString("source_address"); sourcelatitude = jsonObject.getDouble("source_latitude"); sourcelongitude = jsonObject.getDouble("source_longitude"); driverlicense = jsonObject.getString("driverlicense"); driverinsurance = jsonObject.getString("driverinsurance"); Log.d("driveriamge", driverimage); final LatLng loc = new LatLng(new Double(sourcelatitude), new Double(sourcelongitude)); map.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, 15)); MarkerOptions marker = new MarkerOptions().position(loc).title(SourceAddress); marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_three)); map.addMarker(marker); textname.setText(drivername); textmobilenumber.setText(drivermobile); textcompanyname.setText(drivercompanyname); texttaxinumber.setText(drivertexinumber); taxiname.setText(drivertaxiname); mdriverlicense.setText(driverlicense); medriverinsurance.setText(driverinsurance); if (mdriverlicense.length() == 0) { mdriverlicense.setVisibility(View.GONE); } if (medriverinsurance.length() == 0) { medriverinsurance.setVisibility(View.GONE); } Intent intent1 = new Intent(TaxiOntheWay_Activity.this, DriverService.class); intent1.putExtra("driverId", jsonObject.getString("driverId")); startService(intent1); // loc2 = new LatLng(driverlatitude, driverlongitude); // MarkerOptions marker2 = new MarkerOptions().position(loc2); // marker2.icon(BitmapDescriptorFactory.fromResource(R.drawable.drivertaxi)); // map.addMarker(marker2); Timer timer; TimerTask task; int delay = 10000; int period = 10000; timer = new Timer(); timer.scheduleAtFixedRate(task = new TimerTask() { public void run() { runOnUiThread(new Runnable() { @Override public void run() { /*loc2 = new LatLng(new Double(AppPreferences.getCurrentlat(TaxiOntheWay_Activity.this)), new Double(AppPreferences.getCurrentlong(TaxiOntheWay_Activity.this))); MarkerOptions marker2 = new MarkerOptions().position(loc2); map.clear(); marker2.icon(BitmapDescriptorFactory.fromResource(R.drawable.drivertaxi)); map.addMarker(marker2.title(drivername));*/ loc2 = new LatLng(new Double(AppPreferences.getCurrentlat(TaxiOntheWay_Activity.this)), new Double(AppPreferences.getCurrentlong(TaxiOntheWay_Activity.this))); if (marker1 == null) { marker1 = map.addMarker(new MarkerOptions().position(loc2).title(drivername) .icon(BitmapDescriptorFactory.fromResource(R.drawable.drivertaxi))); } animateMarker(marker1, loc2, false); } }); } }, delay, period); } catch (JSONException e) { e.printStackTrace(); } /////////////notification dataend/////////////// fab_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiatePopupWindowcanceltaxi(); } }); fab_msg.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiatePopupWindowsendmesage(); } }); fab_call.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + drivermobile)); startActivity(callIntent); } }); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); if (driverimage.equalsIgnoreCase("")) { mdriverimage.setImageResource(R.drawable.ic_action_user); } else { Picasso.with(getApplicationContext()).load(driverimage).error(R.drawable.ic_action_user) .resize(200, 200).into(mdriverimage); } }