Example usage for java.text DateFormat getDateTimeInstance

List of usage examples for java.text DateFormat getDateTimeInstance

Introduction

In this page you can find the example usage for java.text DateFormat getDateTimeInstance.

Prototype

public static final DateFormat getDateTimeInstance() 

Source Link

Document

Gets the date/time formatter with the default formatting style for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:com.dsi.ant.antplus.pluginsampler.geocache.Dialog_GeoDeviceDetails.java

protected void refreshData() {
    //Set data display with current values
    if (deviceData.programmableData.identificationString != null)
        textView_IdString.setText(String.valueOf(deviceData.programmableData.identificationString));
    if (deviceData.programmableData.PIN != null)
        textView_PIN.setText(String.valueOf(deviceData.programmableData.PIN));
    if (deviceData.programmableData.latitude != null)
        textView_Latitude.setText(//w w  w. ja va2  s .c  o  m
                String.valueOf(deviceData.programmableData.latitude.setScale(5, BigDecimal.ROUND_HALF_UP)));
    if (deviceData.programmableData.longitude != null)
        textView_Longitude.setText(
                String.valueOf(deviceData.programmableData.longitude.setScale(5, BigDecimal.ROUND_HALF_UP)));
    if (deviceData.programmableData.hintString != null)
        textView_HintString.setText(String.valueOf(deviceData.programmableData.hintString));
    if (deviceData.programmableData.lastVisitTimestamp != null) {
        DateFormat df = DateFormat.getDateTimeInstance();
        df.setTimeZone(TimeZone.getTimeZone("UTC"));
        textView_LastVisit.setText(df.format(deviceData.programmableData.lastVisitTimestamp.getTime()));
    }
    if (deviceData.programmableData.numberOfVisits != null)
        textView_NumVisits.setText(String.valueOf(deviceData.programmableData.numberOfVisits));

    textView_HardwareVer.setText(String.valueOf(deviceData.hardwareRevision));
    textView_ManfID.setText(String.valueOf(deviceData.manufacturerID));
    textView_ModelNum.setText(String.valueOf(deviceData.modelNumber));
    textView_SoftwareVer.setText(String.valueOf(deviceData.softwareRevision));
    textView_SerialNum.setText(String.valueOf(deviceData.serialNumber));
    textView_BatteryVoltage.setText(String.valueOf(deviceData.batteryVoltage));
    textView_BatteryStatus.setText(deviceData.batteryStatus.toString());
    textView_OperatingTime.setText(String.valueOf(deviceData.cumulativeOperatingTime));
    textView_OperatingTimeResolution.setText(String.valueOf(deviceData.cumulativeOperatingTimeResolution));
}

From source file:com.spoiledmilk.ibikecph.util.DB.java

private void postHistoryItemToServer(HistoryData hd, HistoryData from, Context context) {
    if (PreferenceManager.getDefaultSharedPreferences(context).contains("auth_token")) {
        String authToken = PreferenceManager.getDefaultSharedPreferences(context).getString("auth_token", "");
        final JSONObject postObject = new JSONObject();
        try {/*from   ww  w .j ava2  s. c  o m*/
            postObject.put("auth_token", authToken);
            JSONObject routeObject = new JSONObject();
            if (from.getName() == null || from.getName().trim().equals("")) {
                from.setName(IbikeApplication.getString("current_position"));
            }
            routeObject.put("from_name", from.getName());
            routeObject.put("from_lattitude", from.getLatitude());
            routeObject.put("from_longitude", from.getLongitude());
            routeObject.put("to_name", hd.getName());
            routeObject.put("to_lattitude", hd.getLatitude());
            routeObject.put("to_longitude", hd.getLongitude());
            routeObject.put("start_date",
                    DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()));
            postObject.put("route", routeObject);
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    LOG.d("Server request: " + Config.serverUrl + "/routes");
                    HttpUtils.postToServer(Config.serverUrl + "/routes", postObject);
                }
            });
            thread.start();
        } catch (JSONException e) {
            LOG.e(e.getLocalizedMessage());
        }
    }

}

From source file:com.eryansky.common.utils.DateUtil.java

/**
 * //from w ww.j a  v a  2  s  .  co  m
 * ??? ? 2008-08-08 16:16:34
 */
public static String addHours(String startDate, int intHour) {
    try {
        DateFormat df = DateFormat.getDateTimeInstance();
        Date date = df.parse(startDate);
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        long longMills = cal.getTimeInMillis() + intHour * 60 * 60 * 1000;
        cal.setTimeInMillis(longMills);

        // 
        return df.format(cal.getTime());
    } catch (Exception Exp) {
        return null;
    }
}

From source file:org.dawnsci.commandserver.ui.view.ConsumerView.java

protected void createColumns() {

    final TableViewerColumn name = new TableViewerColumn(viewer, SWT.LEFT);
    name.getColumn().setText("Name");
    name.getColumn().setWidth(300);/*from www.  j  a  v a2s .  c o m*/
    name.setLabelProvider(new ColumnLabelProvider() {
        public String getText(Object element) {
            return ((ConsumerBean) element).getName();
        }
    });

    final TableViewerColumn status = new TableViewerColumn(viewer, SWT.CENTER);
    status.getColumn().setText("Status");
    status.getColumn().setWidth(100);
    status.setLabelProvider(new ColumnLabelProvider() {
        public String getText(Object element) {
            final ConsumerBean cbean = (ConsumerBean) element;
            ConsumerStatus status = cbean.getStatus();
            if (cbean.getLastAlive() > (System.currentTimeMillis() - Constants.NOTIFICATION_FREQUENCY * 10)
                    && cbean.getLastAlive() < (System.currentTimeMillis()
                            - Constants.NOTIFICATION_FREQUENCY * 2)) {
                status = ConsumerStatus.STOPPING;

            } else if (cbean
                    .getLastAlive() < (System.currentTimeMillis() - Constants.NOTIFICATION_FREQUENCY * 10)) {
                status = ConsumerStatus.STOPPED;
            }
            return status.toString();
        }
    });

    final TableViewerColumn startDate = new TableViewerColumn(viewer, SWT.CENTER);
    startDate.getColumn().setText("Date Started");
    startDate.getColumn().setWidth(150);
    startDate.setLabelProvider(new ColumnLabelProvider() {
        public String getText(Object element) {
            try {
                return DateFormat.getDateTimeInstance()
                        .format(new Date(((ConsumerBean) element).getStartTime()));
            } catch (Exception e) {
                return e.getMessage();
            }
        }
    });

    final TableViewerColumn host = new TableViewerColumn(viewer, SWT.CENTER);
    host.getColumn().setText("Host");
    host.getColumn().setWidth(150);
    host.setLabelProvider(new ColumnLabelProvider() {
        public String getText(Object element) {
            try {
                return ((ConsumerBean) element).getHostName();
            } catch (Exception e) {
                return e.getMessage();
            }
        }
    });

    final TableViewerColumn lastAlive = new TableViewerColumn(viewer, SWT.CENTER);
    lastAlive.getColumn().setText("Last Alive");
    lastAlive.getColumn().setWidth(150);
    lastAlive.setLabelProvider(new ColumnLabelProvider() {
        public String getText(Object element) {
            try {
                return DateFormat.getDateTimeInstance()
                        .format(new Date(((ConsumerBean) element).getLastAlive()));
            } catch (Exception e) {
                return e.getMessage();
            }
        }
    });

    final TableViewerColumn age = new TableViewerColumn(viewer, SWT.CENTER);
    age.getColumn().setText("Age");
    age.getColumn().setWidth(150);
    age.setLabelProvider(new ColumnLabelProvider() {
        public String getText(Object element) {
            try {
                final ConsumerBean cbean = (ConsumerBean) element;
                return (new SimpleDateFormat("dd'd' mm'm' ss's'"))
                        .format(new Date(cbean.getLastAlive() - cbean.getStartTime()));
            } catch (Exception e) {
                return e.getMessage();
            }
        }
    });

}

From source file:ape.Main.java

/**
 * This method logs the current time into the ape.log file
 *//*from   w  ww .  jav  a2 s.c  o  m*/
private static void logTime() {
    // Get a Date object with the current date and time
    Date d = new Date();

    // Log it in a format like so: Aug 11, 2011 11:51:21 AM
    logger.info(DateFormat.getDateTimeInstance().format(d));
}

From source file:com.eryansky.common.utils.DateUtil.java

/**
 * //from w  ww  .ja  va  2  s.co m
 * ???? ? 2008-08-08 16:16:34
 */
public static String delHours(String startDate, int intHour) {
    try {
        DateFormat df = DateFormat.getDateTimeInstance();
        Date date = df.parse(startDate);
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        long longMills = cal.getTimeInMillis() - intHour * 60 * 60 * 1000;
        cal.setTimeInMillis(longMills);

        // 
        return df.format(cal.getTime());
    } catch (Exception Exp) {
        return null;
    }
}

From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.operations.FetchActivityOperation.java

private void handleActivityMetadata(byte[] value) {
    if (value.length == 15) {
        // first two bytes are whether our request was accepted
        if (ArrayUtils.equals(value, MiBand2Service.RESPONSE_ACTIVITY_DATA_START_DATE_SUCCESS, 0)) {
            // the third byte (0x01 on success) = ?
            // the 4th - 7th bytes probably somehow represent the number of bytes/packets to expect

            // last 8 bytes are the start date
            Calendar startTimestamp = getSupport()
                    .fromTimeBytes(org.apache.commons.lang3.ArrayUtils.subarray(value, 7, value.length));
            setStartTimestamp(startTimestamp);

            GB.toast(/*ww w  .j  a v  a  2  s.  c o  m*/
                    getContext().getString(R.string.FetchActivityOperation_about_to_transfer_since,
                            DateFormat.getDateTimeInstance().format(startTimestamp.getTime())),
                    Toast.LENGTH_LONG, GB.INFO);
        } else {
            LOG.warn("Unexpected activity metadata: " + Logging.formatBytes(value));
            handleActivityFetchFinish();
        }
    } else if (value.length == 3) {
        if (Arrays.equals(MiBand2Service.RESPONSE_FINISH_SUCCESS, value)) {
            handleActivityFetchFinish();
        } else {
            LOG.warn("Unexpected activity metadata: " + Logging.formatBytes(value));
            handleActivityFetchFinish();
        }
    }
}

From source file:org.dawnsci.commandserver.ui.view.StatusQueueView.java

private void createActions() {

    final IContributionManager toolMan = getViewSite().getActionBars().getToolBarManager();
    final MenuManager menuMan = new MenuManager();

    final Action openResults = new Action("Open results for selected run",
            Activator.getDefault().getImageDescriptor("icons/results.png")) {
        public void run() {
            openResults(getSelection());
        }//from  w  w w  .ja  v a2 s .  c om
    };

    toolMan.add(openResults);
    menuMan.add(openResults);
    toolMan.add(new Separator());
    menuMan.add(new Separator());

    this.kill = new Action("Terminate job", Activator.getDefault().getImageDescriptor("icons/terminate.png")) {
        public void run() {

            final StatusBean bean = getSelection();
            if (bean == null)
                return;

            if (bean.getStatus().isFinal()) {
                MessageDialog.openInformation(getViewSite().getShell(), "Run '" + bean.getName() + "' inactive",
                        "Run '" + bean.getName() + "' is inactive and cannot be terminated.");
                return;
            }
            try {

                final DateFormat format = DateFormat.getDateTimeInstance();
                boolean ok = MessageDialog.openQuestion(getViewSite().getShell(),
                        "Confirm terminate " + bean.getName(),
                        "Are you sure you want to terminate " + bean.getName() + " submitted on "
                                + format.format(new Date(bean.getSubmissionTime())) + "?");

                if (!ok)
                    return;

                bean.setStatus(org.dawnsci.commandserver.core.beans.Status.REQUEST_TERMINATE);
                bean.setMessage("Requesting a termination of " + bean.getName());
                JSONUtils.sendTopic(bean, getTopicName(), getUri());

            } catch (Exception e) {
                ErrorDialog.openError(getViewSite().getShell(), "Cannot terminate " + bean.getName(),
                        "Cannot terminate " + bean.getName()
                                + "\n\nPlease contact your support representative.",
                        new Status(IStatus.ERROR, "org.dawnsci.commandserver.ui", e.getMessage()));
            }
        }
    };
    toolMan.add(kill);
    menuMan.add(kill);

    final Action rerun = new Action("Rerun", Activator.getDefault().getImageDescriptor("icons/rerun.png")) {
        public void run() {
            rerunSelection();
        }
    };
    toolMan.add(rerun);
    menuMan.add(rerun);

    toolMan.add(new Separator());
    menuMan.add(new Separator());

    final Action showAll = new Action("Show all reruns", IAction.AS_CHECK_BOX) {
        public void run() {
            showEntireQueue = isChecked();
            viewer.refresh();
        }
    };
    showAll.setImageDescriptor(Activator.getDefault().getImageDescriptor("icons/spectacle-lorgnette.png"));

    toolMan.add(showAll);
    menuMan.add(showAll);

    toolMan.add(new Separator());
    menuMan.add(new Separator());

    final Action refresh = new Action("Refresh",
            Activator.getDefault().getImageDescriptor("icons/arrow-circle-double-135.png")) {
        public void run() {
            reconnect();
        }
    };

    toolMan.add(refresh);
    menuMan.add(refresh);

    final Action configure = new Action("Configure...",
            Activator.getDefault().getImageDescriptor("icons/document--pencil.png")) {
        public void run() {
            PropertiesDialog dialog = new PropertiesDialog(getSite().getShell(), idProperties);

            int ok = dialog.open();
            if (ok == PropertiesDialog.OK) {
                idProperties.clear();
                idProperties.putAll(dialog.getProps());
                reconnect();
            }
        }
    };

    toolMan.add(configure);
    menuMan.add(configure);

    viewer.getControl().setMenu(menuMan.createContextMenu(viewer.getControl()));
}

From source file:com.clustercontrol.custom.factory.RunCustom.java

/**
 * ????<br/>//  w ww . jav  a  2 s.c  o m
 * @throws HinemosUnknown ??????
 * @throws MonitorNotFound ??????
 * @throws CustomInvalid ??????
 */
@Override
public void monitor() throws HinemosUnknown, MonitorNotFound, CustomInvalid {
    // Local Variables
    MonitorInfo monitor = null;

    int priority = PriorityConstant.TYPE_UNKNOWN;
    String facilityPath = "";
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dateFormat.setTimeZone(HinemosTime.getTimeZone());
    String executeDate = "";
    String exitDate = "";
    String collectDate = "";
    String msg = "";
    String msgOrig = "";
    double value = -1;

    boolean isMonitorJob = result.getRunInstructionInfo() != null;

    // MAIN
    try {
        monitor = new MonitorSettingControllerBean().getMonitor(result.getMonitorId());

        facilityPath = new RepositoryControllerBean().getFacilityPath(result.getFacilityId(), null);
        executeDate = dateFormat.format(result.getExecuteDate());
        exitDate = dateFormat.format(result.getExitDate());
        collectDate = dateFormat.format(result.getCollectDate());

        if (result.getTimeout() || result.getStdout() == null || "".equals(result.getStdout())
                || result.getResults() == null) {
            if (m_log.isDebugEnabled()) {
                m_log.debug("command monitoring : timeout or no stdout [" + result + "]");
            }

            // if command execution failed (timeout or no stdout)
            if (isMonitorJob || monitor.getMonitorFlg()) {
                msg = "FAILURE : command execution failed (timeout, no stdout or not unexecutable command)...";
                msgOrig = "FAILURE : command execution failed (timeout, no stdout or unexecutable command)...\n\n"
                        + "COMMAND : " + result.getCommand() + "\n" + "COLLECTION DATE : " + collectDate + "\n"
                        + "executed at " + executeDate + "\n" + "exited (or timeout) at " + exitDate + "\n"
                        + "EXIT CODE : " + (result.getExitCode() != null ? result.getExitCode() : "timeout")
                        + "\n\n" + "[STDOUT]\n" + result.getStdout() + "\n" + "[STDERR]\n" + result.getStderr()
                        + "\n";
                // 
                if (!isMonitorJob) {
                    notify(PriorityConstant.TYPE_UNKNOWN, monitor, result.getFacilityId(), facilityPath, null,
                            msg, msgOrig, HinemosModuleConstant.MONITOR_CUSTOM_N);
                } else {
                    // 
                    this.monitorJobEndNodeList.add(new MonitorJobEndNode(result.getRunInstructionInfo(),
                            HinemosModuleConstant.MONITOR_CUSTOM_N, makeJobOrgMessage(monitor, msgOrig), "",
                            RunStatusConstant.END, MonitorJobWorker.getReturnValue(
                                    result.getRunInstructionInfo(), PriorityConstant.TYPE_UNKNOWN)));
                }
            }
        } else {
            List<Sample> sampleList = new ArrayList<Sample>();
            // if command stdout was returned
            for (String key : result.getResults().keySet()) {
                if (m_log.isDebugEnabled()) {
                    m_log.debug("command monitoring : judgement values [" + result + ", key = " + key + "]");
                }
                if (isMonitorJob || monitor.getMonitorFlg()) { // monitor each value
                    // 
                    if (monitor.getCustomCheckInfo().getConvertFlg() == ConvertValueConstant.TYPE_NO) {
                        priority = judgePriority((Double) result.getResults().get(key));

                        msg = "VALUE : " + key + "=" + result.getResults().get(key);
                        msgOrig = "VALUE : " + key + "=" + result.getResults().get(key) + "\n\n" + "COMMAND : "
                                + result.getCommand() + "\n" + "COLLECTION DATE : " + collectDate + "\n"
                                + "executed at " + executeDate + "\n" + "exited (or timeout) at " + exitDate
                                + "\n" + "EXIT CODE : "
                                + (result.getExitCode() != null ? result.getExitCode() : "timeout") + "\n\n"
                                + "[STDOUT]\n" + result.getStdout() + "\n\n" + "[STDERR]\n" + result.getStderr()
                                + "\n";

                        if (!isMonitorJob) {
                            // 
                            notify(priority, monitor, result.getFacilityId(), facilityPath, key, msg, msgOrig,
                                    HinemosModuleConstant.MONITOR_CUSTOM_N);
                        } else {
                            // 
                            this.monitorJobEndNodeList.add(new MonitorJobEndNode(result.getRunInstructionInfo(),
                                    HinemosModuleConstant.MONITOR_CUSTOM_N, makeJobOrgMessage(monitor, msgOrig),
                                    "", RunStatusConstant.END,
                                    MonitorJobWorker.getReturnValue(result.getRunInstructionInfo(), priority)));
                        }

                    } else if (monitor.getCustomCheckInfo()
                            .getConvertFlg() == ConvertValueConstant.TYPE_DELTA) {
                        // ?????????
                        // ??
                        MonitorCustomValue valueEntity = null;
                        Double prevValue = 0d;
                        Long prevDate = 0l;

                        // cache??
                        if (!isMonitorJob) {
                            // 
                            valueEntity = MonitorCustomCache.getMonitorCustomValue(monitor.getMonitorId(),
                                    monitor.getFacilityId());

                            prevValue = (Double) valueEntity.getValue();
                            // ???
                            if (valueEntity.getGetDate() != null) {
                                prevDate = valueEntity.getGetDate();
                            }
                        } else {
                            // 
                            valueEntity = (MonitorCustomValue) MonitorJobWorker
                                    .getPrevMonitorValue(result.getRunInstructionInfo());
                            if (valueEntity != null) {
                                // ????
                                prevValue = (Double) valueEntity.getValue();
                                prevDate = valueEntity.getGetDate();

                            } else {
                                valueEntity = new MonitorCustomValue(new MonitorCustomValuePK(
                                        monitor.getMonitorId(), monitor.getFacilityId()));
                            }
                        }

                        // ????
                        valueEntity.setValue(result.getResults().get(key));
                        valueEntity.setGetDate(result.getCollectDate());

                        if (!isMonitorJob) {
                            // ???ID?????
                            MonitorCustomCache.update(monitor.getMonitorId(), monitor.getFacilityId(),
                                    valueEntity);

                            int m_validSecond = HinemosPropertyUtil
                                    .getHinemosPropertyNum("monitor.custom.valid.second", Long.valueOf(15))
                                    .intValue();
                            // ???????????
                            int tolerance = (monitor.getRunInterval() + m_validSecond) * 1000;

                            if (prevDate > result.getCollectDate() - tolerance) {
                                if (prevValue == null) {
                                    m_log.debug("collect() : prevValue is null");
                                    notify(PriorityConstant.TYPE_UNKNOWN, monitor, result.getFacilityId(),
                                            facilityPath, null, msg, msgOrig,
                                            HinemosModuleConstant.MONITOR_CUSTOM_N);
                                    return;
                                }
                                value = (Double) result.getResults().get(key) - prevValue;
                            } else {
                                if (prevDate != 0l) {
                                    DateFormat df = DateFormat.getDateTimeInstance();
                                    df.setTimeZone(HinemosTime.getTimeZone());
                                    String[] args = { df.format(new Date(prevDate)) };
                                    msg = MessageConstant.MESSAGE_TOO_OLD_TO_CALCULATE.getMessage(args);
                                    notify(PriorityConstant.TYPE_UNKNOWN, monitor, result.getFacilityId(),
                                            facilityPath, null, msg, msgOrig,
                                            HinemosModuleConstant.MONITOR_CUSTOM_N);
                                    return;
                                } else {
                                    // ??????????
                                    return;
                                }
                            }
                            priority = judgePriority(value);

                            msg = "DIFF VALUE : " + key + "=" + value;
                            msgOrig = "DIFF VALUE : " + key + "=" + value + "\n" + "CURRENT VALUE : " + key
                                    + "=" + result.getResults().get(key) + "\n" + "PREVIOUS VALUE : " + key
                                    + "=" + prevValue + "\n\n" + "COMMAND : " + result.getCommand() + "\n"
                                    + "COLLECTION DATE : " + collectDate + "\n" + "executed at " + executeDate
                                    + "\n" + "exited (or timeout) at " + exitDate + "\n" + "EXIT CODE : "
                                    + (result.getExitCode() != null ? result.getExitCode() : "timeout") + "\n\n"
                                    + "[STDOUT]\n" + result.getStdout() + "\n\n" + "[STDERR]\n"
                                    + result.getStderr() + "\n";
                            notify(priority, monitor, result.getFacilityId(), facilityPath, key, msg, msgOrig,
                                    HinemosModuleConstant.MONITOR_CUSTOM_N);
                        } else {
                            if (prevDate != 0l) {
                                // ????
                                value = (Double) result.getResults().get(key) - prevValue;
                                priority = judgePriority(value);

                                msg = "DIFF VALUE : " + key + "=" + value;
                                msgOrig = "DIFF VALUE : " + key + "=" + value + "\n" + "CURRENT VALUE : " + key
                                        + "=" + result.getResults().get(key) + "\n" + "PREVIOUS VALUE : " + key
                                        + "=" + prevValue + "\n\n" + "COMMAND : " + result.getCommand() + "\n"
                                        + "COLLECTION DATE : " + collectDate + "\n" + "executed at "
                                        + executeDate + "\n" + "exited (or timeout) at " + exitDate + "\n"
                                        + "EXIT CODE : "
                                        + (result.getExitCode() != null ? result.getExitCode() : "timeout")
                                        + "\n\n" + "[STDOUT]\n" + result.getStdout() + "\n\n" + "[STDERR]\n"
                                        + result.getStderr() + "\n";
                                // 
                                this.monitorJobEndNodeList.add(new MonitorJobEndNode(
                                        result.getRunInstructionInfo(), HinemosModuleConstant.MONITOR_CUSTOM_N,
                                        makeJobOrgMessage(monitor, msgOrig), "", RunStatusConstant.END,
                                        MonitorJobWorker.getReturnValue(result.getRunInstructionInfo(),
                                                priority)));
                            } else {
                                // ??????
                                MonitorJobWorker.addPrevMonitorValue(result.getRunInstructionInfo(),
                                        valueEntity);
                            }
                        }
                    }
                }

                if (!isMonitorJob && monitor.getCollectorFlg()) { // collector each value
                    Sample sample = new Sample(
                            result.getCollectDate() == null ? null : new Date(result.getCollectDate()),
                            monitor.getMonitorId());
                    // 
                    if (monitor.getCustomCheckInfo().getConvertFlg() == ConvertValueConstant.TYPE_NO) {
                        sample.set(result.getFacilityId(), monitor.getItemName(),
                                (Double) result.getResults().get(key), CollectedDataErrorTypeConstant.NOT_ERROR,
                                key);
                    } else if (monitor.getCustomCheckInfo()
                            .getConvertFlg() == ConvertValueConstant.TYPE_DELTA) {
                        sample.set(result.getFacilityId(), monitor.getItemName(), value,
                                CollectedDataErrorTypeConstant.NOT_ERROR, key);
                    }
                    sampleList.add(sample);
                }
            }
            if (!sampleList.isEmpty()) {
                CollectDataUtil.put(sampleList);
            }
            if (isMonitorJob || monitor.getMonitorFlg()) { // notify invalid lines of stdout
                for (Integer lineNum : result.getInvalidLines().keySet()) {
                    if (m_log.isDebugEnabled()) {
                        m_log.debug("command monitoring : notify invalid result [" + result + ", lineNum = "
                                + lineNum + "]");
                    }
                    msg = "FAILURE : invalid line found (not 2 column or duplicate) - (line " + lineNum + ") "
                            + result.getInvalidLines().get(lineNum);
                    msgOrig = "FAILURE : invalid line found (not 2 column or duplicate) - (line " + lineNum
                            + ") " + result.getInvalidLines().get(lineNum) + "\n\n" + "COMMAND : "
                            + result.getCommand() + "\n" + "COLLECTION DATE : " + collectDate + "\n"
                            + "executed at " + executeDate + "\n" + "exited (or timeout) at " + exitDate + "\n"
                            + "EXIT CODE : " + (result.getExitCode() != null ? result.getExitCode() : "timeout")
                            + "\n\n" + "[STDOUT]\n" + result.getStdout() + "\n\n" + "[STDERR]\n"
                            + result.getStderr() + "\n";

                    if (!isMonitorJob) {
                        // 
                        notify(PriorityConstant.TYPE_UNKNOWN, monitor, result.getFacilityId(), facilityPath,
                                lineNum.toString(), msg, msgOrig, HinemosModuleConstant.MONITOR_CUSTOM_N);
                    } else {
                        // 
                        this.monitorJobEndNodeList.add(new MonitorJobEndNode(result.getRunInstructionInfo(),
                                HinemosModuleConstant.MONITOR_CUSTOM_N, makeJobOrgMessage(monitor, msgOrig), "",
                                RunStatusConstant.END, MonitorJobWorker.getReturnValue(
                                        result.getRunInstructionInfo(), PriorityConstant.TYPE_UNKNOWN)));
                    }
                }
            }
        }
    } catch (MonitorNotFound e) {
        m_log.warn("unexpected internal failure occurred. [" + result + "]");
        throw e;
    } catch (CustomInvalid e) {
        m_log.warn("unexpected internal failure occurred. [" + result + "]");
        throw e;
    } catch (HinemosUnknown e) {
        m_log.warn("unexpected internal failure occurred. [" + result + "]");
        throw e;
    } catch (Exception e) {
        m_log.warn("unexpected internal failure occurred. [" + result + "]", e);
        throw new HinemosUnknown("unexpected internal failure occurred. [" + result + "]", e);
    }
}

From source file:Senku.java

/**
 * Crear archivo CSV con histrico de partidas
 *
 * @param millis long indicando milisegundos para contar el tiempo
 *//*from  w  w w.  j  ava  2 s  .  c o m*/
public void createCSV() {
    Calendar calendar = Calendar.getInstance();
    DateFormat formato = DateFormat.getDateTimeInstance();

    try {

        bf = new BufferedWriter(new FileWriter(file, true));
        if (file.length() == 0) {
            bf.write("Date and Time; Board Name; Remaining Chips; Match Time");
            bf.newLine();
        }
        bf.append(formato.format(calendar.getTime()) + "; " + this.getBoardName() + "; " + this.ballcounter
                + "; " + DurationFormatUtils.formatDuration(timeCounter.getTime(), "mm:ss"));
        bf.newLine();

    } catch (IOException ex) {
        Logger.getLogger(Senku.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            if (bf != null) {
                bf.close();
            }
        } catch (Exception e) {
            Logger.getLogger(Senku.class.getName()).log(Level.SEVERE, null, e);
        }
    }
    timeCounter.reset();
}