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.eleybourn.bookcatalogue.utils.Utils.java

public static String toPrettyDateTime(Date d) {
    return DateFormat.getDateTimeInstance().format(d);
}

From source file:gov.whitehouse.ui.fragments.app.ArticleListFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    FeedItem item = mFeedItems.get(position);

    Bundle args = new Bundle();
    if (mFeedType == ARTICLE_TYPE_FAVORITES && item.getType() == TYPE_VIDEO) {
        args.putString(VideoPlayerActivity.ARG_ITEM_JSON, GsonUtils.toJson(item));
        args.putString(VideoPlayerActivity.ARG_UP_TITLE, getString(R.string.favorites));
        final Intent nextIntent = new Intent(getSherlockActivity(), VideoPlayerActivity.class);
        nextIntent.putExtras(args);//w  w  w  .j a  v a 2 s.  co  m
        startActivity(nextIntent);
        return;
    } else {
        args.putInt(ARG_FEED_TYPE, mFeedType);
        args.putString(ARG_UP_TITLE, mFeedTitle);
        args.putString(ARG_ITEM_JSON, GsonUtils.toJson(item));
        args.putString("title", item.getTitle());
        DateFormat formatter = DateFormat.getDateTimeInstance();
        args.putString("date", formatter.format(item.getPubDate()));
        args.putString("creator", item.getCreator());
        args.putString("description", item.getDescription());
        args.putString("url", item.getLink().toString());
    }

    final BaseActivity activity = (BaseActivity) getSherlockActivity();
    if (activity.isMultipaned()) {
        // track multi-pane article views here
        GATrackingManager.getInstance().track(activity.getTrackingPathComponent(), item.getTitle());

        ArticleViewerFragment detailsFragment = new ArticleViewerFragment();
        detailsFragment.setArguments(args);
        activity.getSupportFragmentManager().beginTransaction().replace(R.id.details_container, detailsFragment)
                .commit();
    } else {
        final Intent nextIntent = new Intent(getSherlockActivity(), ArticleViewerActivity.class);
        nextIntent.putExtras(args);
        startActivity(nextIntent);
    }
}

From source file:com.corporatetaxi.TaxiArrived_Acitivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_taxiarrived);
    taxiArrived_AcitivityInstance = this;
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.BLACK);
    setSupportActionBar(toolbar);/*from  ww  w .j  av a  2s. co  m*/
    // getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    String title = getString(R.string.title_activity_taxidetail);
    getSupportActionBar().setTitle(title);
    txt_header = (TextView) findViewById(R.id.textheader);
    fab_menu = (FloatingActionsMenu) findViewById(R.id.fab_menu);
    fab_msg = (FloatingActionButton) findViewById(R.id.fab_message);
    fab_boarded = (FloatingActionButton) findViewById(R.id.fab_boarded);
    fab_cancel = (FloatingActionButton) findViewById(R.id.fab_cancel);

    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);
    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);
    taxiname = (TextView) findViewById(R.id.taxinametext);
    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");
    txt_header.setTypeface(tf);

    mtextnamehead.setTypeface(tf);
    mtextcompanyhead.setTypeface(tf);
    mtextmobilehead.setTypeface(tf);
    mtexttexinumhead.setTypeface(tf);
    taxinamehead.setTypeface(tf);
    taxiname.setTypeface(tf);
    textname.setTypeface(tf);
    textmobilenumber.setTypeface(tf);
    textcompanyname.setTypeface(tf);
    texttaxinumber.setTypeface(tf);
    mdriverlicense.setTypeface(tf);
    medriverinsurance.setTypeface(tf);
    /////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);

    ////////current date time//////////////////
    currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
    Log.d("currentdatetime", currentDateTimeString);
    //caceldialog();
    /////////////notification data///////////////
    Intent intent = getIntent();
    String data = intent.getStringExtra("data");

    Log.d("data value", data + "");
    try {
        JSONObject jsonObject = new JSONObject(data);
        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");
        tripamount = jsonObject.getString("amount");
        Log.d("amooo", tripamount);
        tripdestination = jsonObject.getString("destination");
        corporateusercompany = jsonObject.getString("corporatecompany");
        SourceAddress = jsonObject.getString("source_address");
        sourcelatitude = jsonObject.getDouble("source_latitude");
        sourcelongitude = jsonObject.getDouble("source_longitude");
        driverlicense = jsonObject.getString("driverlicense");
        driverinsurance = jsonObject.getString("driverinsurance");

        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);

        Log.d("driveriamge", driverimage);
        Log.d("longitudeeeee:------", String.valueOf(jsonObject.getDouble("longitude")));

        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);
        }
        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);
        }

        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(TaxiArrived_Acitivity.this)),
                            new Double(AppPreferences.getCurrentlong(TaxiArrived_Acitivity.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(TaxiArrived_Acitivity.this)),
                                new Double(AppPreferences.getCurrentlong(TaxiArrived_Acitivity.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_boarded.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent1 = new Intent(TaxiArrived_Acitivity.this, Payment_Activity.class);

            intent1.putExtra("driver_companyname", drivercompanyname);
            intent1.putExtra("trip_amount", tripamount);
            intent1.putExtra("trip_destination", tripdestination);
            intent1.putExtra("user_company", corporateusercompany);
            intent1.putExtra("driver_image", driverimage);
            intent1.putExtra("drver_name", drivername);
            intent1.putExtra("driver_mobile", drivermobile);
            intent1.putExtra("driver_taxinumber", drivertexinumber);
            intent1.putExtra("driver_taxiname", drivertaxiname);
            startActivity(intent1);

            new BoardeTripAsynch().execute();

        }
    });
    fab_msg.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            initiatePopupWindowsendmesage();
        }
    });

}

From source file:com.example.styleddialog.MyActivity.java

@Override
public void onPositiveButtonClicked(int resultCode, Date date) {
    String text = "";
    if (resultCode == 12) {
        text = "Date ";
    } else if (resultCode == 13) {
        text = "Time ";
    }/*from  w  w w.  j  a v a2s  . c  om*/

    DateFormat dateFormat = DateFormat.getDateTimeInstance();
    Toast.makeText(this, text + "Success! " + dateFormat.format(date), Toast.LENGTH_SHORT).show();
}

From source file:com.clustercontrol.snmp.factory.RunMonitorSnmp.java

/**
 * OID?/*  w  w w.j a v a 2s .co  m*/
 * 
 * @param facilityId ID
 * @return ???????true
 * @throws HinemosUnknown
 */
@Override
public boolean collect(String facilityId) throws HinemosUnknown {

    if (m_now != null) {
        m_nodeDate = m_now.getTime();
    }
    m_value = 0;

    // 
    m_message = "";
    m_messageOrg = MessageConstant.OID.getMessage() + " : " + m_snmpOid;

    NodeInfo info = null;
    try {
        // ??
        info = new RepositoryControllerBean().getNode(facilityId);
    } catch (FacilityNotFound e) {
        m_message = MessageConstant.MESSAGE_COULD_NOT_GET_NODE_ATTRIBUTES.getMessage();
        m_messageOrg = m_messageOrg + " (" + e.getMessage() + ")";
        resetCache(m_monitorId, facilityId);
        return false;
    }

    // SNMP?
    RequestSnmp4j m_request = new RequestSnmp4j();

    m_log.debug("version=" + info.getSnmpVersion());
    boolean result = false;
    try {
        result = m_request.polling(info.getAvailableIpAddress(), info.getSnmpCommunity(), info.getSnmpPort(),
                m_snmpOid, info.getSnmpVersion(), info.getSnmpTimeout(), info.getSnmpRetryCount(),
                info.getSnmpSecurityLevel(), info.getSnmpUser(), info.getSnmpAuthPassword(),
                info.getSnmpPrivPassword(), info.getSnmpAuthProtocol(), info.getSnmpPrivProtocol());
    } catch (Exception e) {
        m_message = MessageConstant.MESSAGE_COULD_NOT_GET_NODE_ATTRIBUTES.getMessage();
        m_messageOrg = m_message + ", " + e.getMessage() + " (" + e.getClass().getName() + ")";
        if (e instanceof NumberFormatException) {
            m_log.warn(m_messageOrg);
        } else {
            m_log.warn(m_messageOrg, e);
        }
        resetCache(m_monitorId, facilityId);
        return false;
    }

    if (result) {

        // ??
        double value = -1;
        try {
            if (m_request.getValue() == null) {
                m_log.debug("collect() : m_request.getValue() is null");
                return false;
            }
            value = Double.parseDouble(m_request.getValue());
        } catch (NumberFormatException e) {
            m_log.info("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
            String[] args = { m_request.getValue() };
            m_message = MessageConstant.MESSAGE_COULD_NOT_GET_NUMERIC_VALUE.getMessage(args);
            resetCache(m_monitorId, facilityId);
            return false;
        } catch (Exception e) {
            m_log.warn("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
            String[] args = { m_request.getValue() };
            m_message = MessageConstant.MESSAGE_COULD_NOT_GET_NUMERIC_VALUE.getMessage(args);
            resetCache(m_monitorId, facilityId);
            return false;
        }
        long date = m_request.getDate();

        // ????
        if (m_convertFlg == ConvertValueConstant.TYPE_NO) {
            m_value = value;
            m_nodeDate = date;
        }
        // ??
        else if (m_convertFlg == ConvertValueConstant.TYPE_DELTA) {
            // ??
            MonitorSnmpValue valueEntity = null;
            Double prevValue = 0d;
            Long prevDate = 0l;
            if (!m_isMonitorJob) {
                // ??
                // cache??
                valueEntity = MonitorSnmpCache.getMonitorSnmpValue(m_monitorId, facilityId);

                // ???
                prevValue = valueEntity.getValue();
                if (valueEntity.getGetDate() != null) {
                    prevDate = valueEntity.getGetDate();
                }
            } else {
                // ??
                valueEntity = new MonitorSnmpValue(new MonitorSnmpValuePK(m_monitorId, facilityId));
                if (m_prvData instanceof MonitorSnmpValue) {
                    // ????
                    prevValue = ((MonitorSnmpValue) m_prvData).getValue();
                    prevDate = ((MonitorSnmpValue) m_prvData).getGetDate();
                }
            }

            if (prevValue != null) {
                if (prevValue > value) {
                    if (m_request.getType() == SMIConstants.SYNTAX_COUNTER32) {
                        value += ((double) Integer.MAX_VALUE + 1) * 2;
                    } else if (m_request.getType() == SMIConstants.SYNTAX_COUNTER64) {
                        value += ((double) Long.MAX_VALUE + 1) * 2;
                    }
                }
            }

            // SNMP????
            valueEntity.setValue(Double.valueOf(value));
            valueEntity.setGetDate(date);

            if (!m_isMonitorJob) {
                // ???ID?????
                if (m_monitor.getMonitorFlg())
                    MonitorSnmpCache.update(m_monitorId, facilityId, valueEntity);

                // ???SNMP????????
                int tolerance = (m_runInterval + SnmpProperties.getProperties().getValidSecond()) * 1000;

                if (prevDate > date - tolerance) {

                    // ??null???
                    if (prevValue == null) {
                        m_log.debug("collect() : prevValue is null");
                        return false;
                    }

                    m_value = value - prevValue;
                    m_nodeDate = m_request.getDate();
                } 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 = value - prevValue;
                m_nodeDate = m_request.getDate();
                m_curData = valueEntity;
            }

        }
        m_message = MessageConstant.SELECT_VALUE.getMessage() + " : " + m_value;
    } else {
        m_message = m_request.getMessage();
        resetCache(m_monitorId, facilityId);
    }
    return result;
}

From source file:com.alkacon.opencms.formgenerator.database.export.CmsCvsExportBean.java

/**
 * Returns the CSV export file content.<p> 
 * /*w ww.  jav  a 2  s  . co  m*/
 * @param formId the current selected web form
 * @param locale the current local
 * 
 * @return the CSV export file content
 * 
 * @throws SQLException if something goes wrong 
 */
public String exportData(String formId, Locale locale) throws SQLException {

    /*
     * TODO: Access the CmsForm (or CmsFormHandler) and put out all 
     * fields in the exact order - put fields that do not exist any longer 
     * to the back (note: readAllFormFieldNames is required for the old values). 
     */

    StringBuffer result = new StringBuffer();
    CmsModule module = OpenCms.getModuleManager().getModule(CmsForm.MODULE_NAME);

    // time format: 
    DateFormat df = null;
    String formatString = module.getParameter(CmsForm.MODULE_PARAM_EXPORT_TIMEFORMAT);
    if (CmsStringUtil.isNotEmpty(formatString)) {
        try {
            df = new SimpleDateFormat(formatString);
        } catch (IllegalArgumentException iae) {
            LOG.warn(Messages.get().getBundle().key(Messages.LOG_WARN_EXPORT_DATEFORMAT_ILLEGAL_2,
                    new Object[] { CmsForm.MODULE_PARAM_EXPORT_TIMEFORMAT, formatString }));
        }
    }

    // line separator: 
    boolean isWindowsLineSeparator = false;
    boolean isUnixLineSeparator = false;

    String lineSeparatorParam = module.getParameter(CmsForm.MODULE_PARAM_EXPORTLINESEPARATOR);
    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(lineSeparatorParam)) {
        if (lineSeparatorParam.equals(CmsForm.MODULE_PARAMVALUE_EXPORTLINESEPARATOR_WINDOWS)) {
            isWindowsLineSeparator = true;
        } else if (lineSeparatorParam.equals(CmsForm.MODULE_PARAMVALUE_EXPORTLINESEPARATOR_UNIX)
                || lineSeparatorParam.equals(CmsForm.MODULE_PARAMVALUE_EXPORTLINESEPARATOR_EXCEL)) {
            isUnixLineSeparator = true;
        }
    }

    // export numbers as string:
    String nasParam = module.getParameter(CmsForm.MODULE_PARAM_EXPORT_NUMBERASSTRING, CmsStringUtil.FALSE);
    boolean numberAsString = Boolean.valueOf(nasParam).booleanValue();

    // csv delimiter
    String lineSeparator = EXCEL_DEFAULT_CSV_DELMITER;
    String configLineSeparator = module.getParameter(CmsForm.MODULE_PARAM_CSV_DELIMITER);
    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(configLineSeparator)) {

        lineSeparator = configLineSeparator.trim();
    }

    // get the column names
    List<String> columnNames = CmsFormDataAccess.getInstance().readFormFieldNames(formId,
            getStartTime().getTime(), getEndTime().getTime());
    Collections.sort(columnNames, Collator.getInstance(locale));

    // get the entries
    List<CmsFormDataBean> dataEntries = CmsFormDataAccess.getInstance().readForms(formId,
            getStartTime().getTime(), getEndTime().getTime());

    // loop 1 - write the headers:
    result.append(escapeExcelCsv("Creation date", numberAsString));
    result.append(lineSeparator);
    result.append(escapeExcelCsv("Resource path", numberAsString));
    result.append(lineSeparator);
    result.append(escapeExcelCsv("Resource UUID", numberAsString));
    result.append(lineSeparator);
    Iterator<String> itColumns = columnNames.iterator();
    while (itColumns.hasNext()) {
        String columnName = itColumns.next();
        // skip empty columns (previous versions saved CmsEmptyField with empty values which will not be deleted):
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(columnName)) {
            columnName = escapeExcelCsv(columnName, numberAsString);
            result.append(columnName);
            if (itColumns.hasNext()) {
                result.append(lineSeparator);
            }
        }
    }
    result.append("\r\n");
    // loop 2 - write the data:
    Iterator<CmsFormDataBean> itRows = dataEntries.iterator();
    String path;
    CmsUUID uuid = null;
    while (itRows.hasNext()) {
        CmsFormDataBean row = itRows.next();
        // create an entry for each column, even if some rows (data sets) 
        // do not contain the field value because it was 
        // a) not entered 
        // b) the form was changed in structure over time 
        // c) developer errors,  hw /sw problems... 
        Date creationDate = new Date(row.getDateCreated());
        if (df == null) {
            result.append(creationDate);
        } else {
            result.append(df.format(creationDate));
        }
        DateFormat.getDateTimeInstance();
        result.append(lineSeparator);
        uuid = row.getResourceId();
        try {
            path = m_cms.readResource(uuid).getRootPath();
        } catch (Exception e) {
            path = row.getResourceId().toString();
        }
        result.append(path);
        result.append(lineSeparator);
        result.append(String.valueOf(uuid));
        result.append(lineSeparator);
        itColumns = columnNames.iterator();
        while (itColumns.hasNext()) {
            String columnName = itColumns.next();
            // skip empty columns (previous versions saved CmsEmptyField with empty values which will not be deleted):
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(columnName)) {

                String value = row.getFieldValue(columnName);
                if (value != null) {
                    if (isWindowsLineSeparator) {
                        value = transformWindowsLineseparator(value);
                    } else if (isUnixLineSeparator) {
                        value = transformUnixLineseparator(value);
                    }
                    value = escapeExcelCsv(value, numberAsString);
                    result.append(value);
                }
                if (itColumns.hasNext()) {
                    result.append(lineSeparator);
                }
            }
        }
        result.append("\r\n");
    }
    return result.toString();
}

From source file:com.MainFiles.Functions.java

public String DateTime() {
    java.util.Date today = new java.util.Date();

    //Date format
    DateFormat df = DateFormat.getDateTimeInstance(); //Date and time
    String strDate = df.format(today);
    return strDate;
}

From source file:com.clustercontrol.jobmanagement.util.ParameterUtil.java

/**
 *
 * ?????//w  ww .  j  a  v  a  2  s  .c  om
 *
 * @param paramId ID
 * @param sessionId ID
 * @param jobSessionEntity 
 * @return 
 * @throws JobInfoNotFound
 */
private static String getJobSessionValue(String paramId, String sessionId, JobSessionEntity jobSessionEntity)
        throws JobInfoNotFound {

    m_log.debug("getJobSessionValue() start paramId=" + paramId + ",sessionId=" + sessionId);
    String ret = null;

    if (paramId.equals(SystemParameterConstant.SESSION_ID)) {
        // ID
        ret = sessionId;
    } else {
        if (jobSessionEntity == null) {
            HinemosEntityManager em = new JpaTransactionManager().getEntityManager();

            // ??
            jobSessionEntity = em.find(JobSessionEntity.class, sessionId, ObjectPrivilegeMode.READ);
            if (jobSessionEntity == null) {
                JobInfoNotFound je = new JobInfoNotFound(
                        "JobSessionEntity.findByPrimaryKey" + ", sessionId = " + sessionId);
                m_log.info(
                        "getJobParameterValue() : " + je.getClass().getSimpleName() + ", " + je.getMessage());
                je.setSessionId(sessionId);
                throw je;
            }
        }

        if (paramId.equals(SystemParameterConstant.START_DATE)) {
            // 
            DateFormat df = DateFormat.getDateTimeInstance();
            df.setTimeZone(HinemosTime.getTimeZone());
            ret = df.format(jobSessionEntity.getScheduleDate());

        } else if (paramId.equals(SystemParameterConstant.TRIGGER_TYPE)) {
            // ?
            Locale locale = NotifyUtil.getNotifyLocale();
            ret = Messages.getString(
                    JobTriggerTypeConstant.typeToMessageCode(jobSessionEntity.getTriggerType()), locale);

        } else if (paramId.equals(SystemParameterConstant.TRIGGER_INFO)) {
            // ?
            ret = jobSessionEntity.getTriggerInfo();

        }
    }
    m_log.debug("getJobSessionValue() end paramId=" + paramId + ",sessionId=" + sessionId + ",value=" + ret);
    return ret;
}

From source file:org.opendatakit.common.utils.WebUtils.java

/**
 * Parse a string into a datetime value. Tries the common Http formats, the
 * iso8601 format (used by Javarosa), the default formatting from
 * Date.toString(), and a time-only format.
 *
 * @param value//from ww  w.  j  a  v  a2 s . c  om
 * @return
 */
public static final Date parseDate(String value) {
    if (value == null || value.length() == 0)
        return null;

    String[] iso8601Pattern = new String[] { PATTERN_ISO8601 };

    String[] localizedParsePatterns = new String[] {
            // try the common HTTP date formats that have time zones
            PATTERN_RFC1123, PATTERN_RFC1036, PATTERN_DATE_TOSTRING };

    String[] localizedNoTzParsePatterns = new String[] {
            // ones without timezones... (will assume UTC)
            PATTERN_ASCTIME };

    String[] tzParsePatterns = new String[] { PATTERN_ISO8601, PATTERN_ISO8601_DATE, PATTERN_ISO8601_TIME };

    String[] noTzParsePatterns = new String[] {
            // ones without timezones... (will assume UTC)
            PATTERN_ISO8601_WITHOUT_ZONE, PATTERN_NO_DATE_TIME_ONLY, PATTERN_YYYY_MM_DD_DATE_ONLY_NO_TIME_DASH,
            PATTERN_GOOGLE_DOCS };

    Date d = null;
    // iso8601 parsing is sometimes off-by-one when JR does it...
    d = parseDateSubset(value, iso8601Pattern, null, TimeZone.getTimeZone("GMT"));
    if (d != null)
        return d;
    // try to parse with the JavaRosa parsers
    d = DateUtils.parseDateTime(value);
    if (d != null)
        return d;
    d = DateUtils.parseDate(value);
    if (d != null)
        return d;
    d = DateUtils.parseTime(value);
    if (d != null)
        return d;
    // try localized and english text parsers (for Web headers and interactive
    // filter spec.)
    d = parseDateSubset(value, localizedParsePatterns, Locale.ENGLISH, TimeZone.getTimeZone("GMT"));
    if (d != null)
        return d;
    d = parseDateSubset(value, localizedParsePatterns, null, TimeZone.getTimeZone("GMT"));
    if (d != null)
        return d;
    d = parseDateSubset(value, localizedNoTzParsePatterns, Locale.ENGLISH, TimeZone.getTimeZone("GMT"));
    if (d != null)
        return d;
    d = parseDateSubset(value, localizedNoTzParsePatterns, null, TimeZone.getTimeZone("GMT"));
    if (d != null)
        return d;
    // try other common patterns that might not quite match JavaRosa parsers
    d = parseDateSubset(value, tzParsePatterns, null, TimeZone.getTimeZone("GMT"));
    if (d != null)
        return d;
    d = parseDateSubset(value, noTzParsePatterns, null, TimeZone.getTimeZone("GMT"));
    if (d != null)
        return d;
    // try the locale- and timezone- specific parsers
    {
        DateFormat formatter = DateFormat.getDateTimeInstance();
        ParsePosition pos = new ParsePosition(0);
        d = formatter.parse(value, pos);
        if (d != null && pos.getIndex() == value.length()) {
            return d;
        }
    }
    {
        DateFormat formatter = DateFormat.getDateInstance();
        ParsePosition pos = new ParsePosition(0);
        d = formatter.parse(value, pos);
        if (d != null && pos.getIndex() == value.length()) {
            return d;
        }
    }
    {
        DateFormat formatter = DateFormat.getTimeInstance();
        ParsePosition pos = new ParsePosition(0);
        d = formatter.parse(value, pos);
        if (d != null && pos.getIndex() == value.length()) {
            return d;
        }
    }
    throw new IllegalArgumentException("Unable to parse the date: " + value);
}

From source file:com.example.zoetablet.BasicFragmentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //Set the orientation
    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    //Shapes and Coredx DDS Initialization
    // magic to enable WiFi multicast to work on some android platforms:
    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    mcastLock = wifi.createMulticastLock("Tablet");
    mcastLock.acquire();/*from  w  w w . j av  a 2 s.  c om*/

    //Tablet variables
    tablet = new Vector<TabletWriter>();

    // open CoreDX DDS license file:
    BufferedReader br = null;
    String license = new String("<");
    try {
        Log.i("Debug", "...Opening License");
        br = new BufferedReader(new InputStreamReader(this.getAssets().open("coredx_dds.lic")));
    } catch (IOException e) {
        Log.i("Debug", "...License did not open");
        Log.e("Tablet", e.getMessage());
    }
    if (br != null) {
        String ln;
        try {
            while ((ln = br.readLine()) != null) {
                license = new String(license + ln + "\n");
            }
        } catch (IOException e) {
            //  Log.e("Tablet", e.getMessage());
        }
    }
    license = new String(license + ">");
    Log.i("Tablet", "...License seems to be good");

    //Initialize Variables
    XVel = 1;
    YVel = 2;
    CompassDir = 3;
    GPS_LN = 4;
    GPS_LT = 5;
    Log_DDS = DateFormat.getDateTimeInstance().format(new Date());

    //For the Image, use current image display and 
    String fileName = "/storage/sdcard0/DCIM/no_video.jpg";
    Bitmap bmp;
    bmp = BitmapFactory.decodeFile(fileName);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.JPEG, 40, baos);
    buffer = baos.toByteArray();
    data_image_DDS = buffer;

    Log.i("Tablet", "Creating Subscriber");
    class TestDataReaderListener implements DataReaderListener {

        @Override
        public long get_nil_mask() {
            return 0;
        }

        @Override
        public void on_requested_deadline_missed(DataReader dr, RequestedDeadlineMissedStatus status) {
            System.out.println(" @@@@@@@@@@@     REQUESTED DEADLINE MISSED    @@@@@");
            System.out.println(" @@@@@@@@@@@                                  @@@@@");
            System.out.println(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        };

        @Override
        public void on_requested_incompatible_qos(DataReader dr, RequestedIncompatibleQosStatus status) {
            System.out.println(" @@@@@@@@@@@     REQUESTED INCOMPAT QOS    @@@@@@@@");
            System.out.println(" @@@@@@@@@@@        dr      = " + dr);
            System.out.println(" @@@@@@@@@@@                               @@@@@@@@");
            System.out.println(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        };

        @Override
        public void on_sample_rejected(DataReader dr, SampleRejectedStatus status) {
        };

        @Override
        public void on_liveliness_changed(DataReader dr, LivelinessChangedStatus status) {
            TopicDescription td = dr.get_topicdescription();
            System.out.println(" @@@@@@@@@@@     LIVELINESS CHANGED  " + td.get_name() + " @@@@@@@@@@");
        }

        @Override
        public void on_subscription_matched(DataReader dr, SubscriptionMatchedStatus status) {
            TopicDescription td = dr.get_topicdescription();
            System.out.println(" @@@@@@@@@@@     SUBSCRIPTION MATCHED    @@@@@@@@@@");
            System.out.println(
                    " @@@@@@@@@@@        topic   = " + td.get_name() + " (type: " + td.get_type_name() + ")");
            System.out.println(" @@@@@@@@@@@        current = " + status.get_current_count());
            System.out.println(" @@@@@@@@@@@                             @@@@@@@@@@");
            System.out.println(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        }

        @Override
        public void on_sample_lost(DataReader dr, SampleLostStatus status) {
            System.out.println(" @@@@@@@@@@@   SAMPLE LOST    @@@@@@@@@@");
        };

        @Override
        public void on_data_available(DataReader dr) {

            TopicDescription td = dr.get_topicdescription();
            dataDDSDataReader data_message = (dataDDSDataReader) dr;
            System.out.println(" @@@@@@@@@@@     DATA AVAILABLE          @@@@@@@@@@");
            System.out.println(
                    " @@@@@@@@@@@        topic = " + td.get_name() + " (type: " + td.get_type_name() + ")");

            samples = new dataDDSSeq();
            SampleInfoSeq si = new SampleInfoSeq();

            ReturnCode_t retval = data_message.take(samples, si, 100, coredxConstants.DDS_ANY_SAMPLE_STATE,
                    coredxConstants.DDS_ANY_VIEW_STATE, coredxConstants.DDS_ANY_INSTANCE_STATE);
            System.out.println(" @@@@@@@@@@@        DR.read() ===> " + retval);

            if (retval == ReturnCode_t.RETCODE_OK) {
                if (samples.value == null)
                    System.out.println(" @@@@@@@@@@@        samples.value = null");
                else {
                    System.out.println(" @@@@@@@@@@@        samples.value.length= " + samples.value.length);
                    for (int i = 0; i < samples.value.length; i++) {
                        System.out.println("    State       : "
                                + (si.value[i].instance_state == coredxConstants.DDS_ALIVE_INSTANCE_STATE
                                        ? "ALIVE"
                                        : "NOT ALIVE"));
                        System.out.println("    TimeStamp   : " + si.value[i].source_timestamp.sec + "."
                                + si.value[i].source_timestamp.nanosec);
                        System.out.println("    Handle      : " + si.value[i].instance_handle.value);
                        System.out.println("    WriterHandle: " + si.value[i].publication_handle.value);
                        System.out.println("    SampleRank  : " + si.value[i].sample_rank);
                        if (si.value[i].valid_data)
                            System.out.println("       XVel: " + samples.value[i].XVel_DDS);
                        System.out.println("       YVel: " + samples.value[i].YVel_DDS);
                        System.out.println(" CompassDir: " + samples.value[i].CompassDir_DDS);
                        System.out.println("     GPS_LT: " + samples.value[i].GPS_LT_DDS);
                        System.out.println("     GPS_LN: " + samples.value[i].GPS_LN_DDS);
                        System.out.println("     Log_DDS: " + samples.value[i].Log_DDS);

                        //Capture data values for display
                        BasicFragmentActivity.XVel = samples.value[i].XVel_DDS;
                        BasicFragmentActivity.YVel = samples.value[i].YVel_DDS;
                        BasicFragmentActivity.CompassDir = samples.value[i].CompassDir_DDS;
                        BasicFragmentActivity.GPS_LT = samples.value[i].GPS_LT_DDS;
                        BasicFragmentActivity.GPS_LN = samples.value[i].GPS_LN_DDS;
                        BasicFragmentActivity.Log_DDS = samples.value[i].Log_DDS;
                        BasicFragmentActivity.data_image_DDS = samples.value[i].data_image_DDS;
                    }
                }
                data_message.return_loan(samples, si);
            } else {
            }
            System.out.println(" @@@@@@@@@@@                             @@@@@@@@@@");
            System.out.println(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        };
    }
    ;

    System.out.println("STARTING -------------------------");
    DomainParticipantFactory dpf = DomainParticipantFactory.get_instance();
    dpf.set_license(license);
    dpf.get_default_participant_qos(dp_qos_tablet);
    DomainParticipant dp = null;

    System.out.println("CREATE PARTICIPANT ---------------");
    dp = dpf.create_participant(0, /* domain Id   */
            dp_qos_tablet,
            //null, /* default qos */
            null, /* no listener */
            0);

    if (dp == null) {
        //failed to create DomainParticipant -- bad license
        android.util.Log.e("CoreDX DDS", "Unable to create Tablet DomainParticipant.");
    }

    SubscriberQos sub_qos_tablet = new SubscriberQos();
    Log.i("Tablet", "creating publisher/subscriber");
    sub_tablet = dp.create_subscriber(sub_qos_tablet, null, 0);

    System.out.println("REGISTERING TYPE -----------------");
    dataDDSTypeSupport ts = new dataDDSTypeSupport();
    ReturnCode_t returnValue = ts.register_type(dp, null);

    if (returnValue != ReturnCode_t.RETCODE_OK) {
        System.out.println("ERROR registering type\n");
        return;
    }

    System.out.println("CREATE TOPIC ---------------------");

    /* create a DDS Topic with the FilterMsg data type. */
    Topic topics = dp.create_topic("dataDDS", ts.get_type_name(), DDS.TOPIC_QOS_DEFAULT, null, 0);

    if (topics == null) {
        System.out.println("Error creating topic");
        return;
    }

    System.out.println("CREATE SUBSCRIBER ----------------");
    SubscriberQos sub_qos = null;
    SubscriberListener sub_listener = null;
    Subscriber sub = dp.create_subscriber(sub_qos, sub_listener, 0);

    System.out.println("READER VARIABLES ----------------");
    DataReaderQos dr_qos = new DataReaderQos();
    sub.get_default_datareader_qos(dr_qos);
    dr_qos.entity_name.value = "JAVA_DR";
    dr_qos.history.depth = 10;
    DataReaderListener dr_listener = new TestDataReaderListener();

    System.out.println("CREATE DATAREADER ----------------");

    //Create DDS Data reader
    dataDDSDataReader dr = (dataDDSDataReader) sub.create_datareader(topics, DDS.DATAREADER_QOS_DEFAULT,
            dr_listener, DDS.DATA_AVAILABLE_STATUS);

    System.out.println("DATAREADER CREATED ----------------");

    //Cheack to see if DDS Data Reader worked 
    if (dr == null) {
        System.out.println("ERROR creating data reader\n");
        //return;
    }

    // We default to building our Fragment at runtime, but you can switch the layout here
    // to R.layout.activity_fragment_xml in order to have the Fragment added during the
    // Activity's layout inflation.

    setContentView(R.layout.holygrail);
    Log.i("Tablet", "called set content view");

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.center_pane_top); // You can find Fragments just like you would with a 
    // View by using FragmentManager.

    Log.i("Tablet", "...declare fragment");

    // If wLog.ie are using activity_fragment_xml.xml then this the fragment will not be
    // null, otherwise it will be.
    if (fragment == null) {

        //Image View Fragment
        Log.i("Debug", "...calling fragment center pane");
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.center_pane_top, new BasicFragment());
        ft.addToBackStack(null);

        //Logging Fragment
        Log.i("Debug", "...calling fragment left pane top");
        //ft.add(R.id.left_pane_top, new LoggingFragment());
        ft.add(R.id.left_pane_top, new LoggingFragment());
        ft.addToBackStack(null);

        //Connecting Fragment
        Log.i("Debug", "...calling fragment left pane bottom");
        //ft.add(R.id.left_pane_bottom,new ControllerFragment());
        ft.add(R.id.left_pane_bottom, new ConnectionFragment());
        ft.addToBackStack(null);

        //Compass Fragment
        Log.i("Debug", "...calling fragment right pane top");
        //ft.add(R.id.right_pane_top,new BasicFragment2());
        ft.add(R.id.right_pane_top, new BasicFragment2());
        ft.addToBackStack(null);

        //Navigation Fragment
        Log.i("Debug", "...calling fragment right pane bottom");
        //ft.add(R.id.center_pane_bottom,new NavigationFragment());
        ft.add(R.id.center_pane_bottom, new DualJoystickActivity());
        ft.addToBackStack(null);

        //Datalog Fragment
        Log.i("Debug", "...calling fragment middle pane bottom");
        //ft.add(R.id.right_pane_bottom,new DatalogFragment());
        ft.add(R.id.right_pane_bottom, new DatalogFragment());
        ft.addToBackStack(null);

        //Commit the fragment or it will not be added
        Log.i("Debug", "...comitting");
        ft.commit();
    }

    //Joystick variables
    txtX1 = (TextView) this.findViewById(R.id.TextViewX1);
    txtY1 = (TextView) this.findViewById(R.id.TextViewY1);
    txtX2 = (TextView) this.findViewById(R.id.TextViewX2);
    txtY2 = (TextView) this.findViewById(R.id.TextViewY2);
    joystick = (DualJoystickView) this.findViewById(R.id.dualjoystickView);

    JoystickMovedListener _listenerLeft = new JoystickMovedListener() {

        @Override
        public void OnMoved(int pan, int tilt) {
            txtX1.setText(Integer.toString(pan));
            txtY1.setText(Integer.toString(tilt));
        }

        @Override
        public void OnReleased() {
            txtX1.setText("released");
            txtY1.setText("released");
        }

        @Override
        public void OnReturnedToCenter() {
            txtX1.setText("stopped");
            txtY1.setText("stopped");
        };
    };

    JoystickMovedListener _listenerRight = new JoystickMovedListener() {

        @Override
        public void OnMoved(int pan, int tilt) {
            txtX2.setText(Integer.toString(pan));
            txtY2.setText(Integer.toString(tilt));
        }

        @Override
        public void OnReleased() {
            txtX2.setText("released");
            txtY2.setText("released");
        }

        @Override
        public void OnReturnedToCenter() {
            txtX2.setText("stopped");
            txtY2.setText("stopped");
        };
    };

    joystick.setOnJostickMovedListener(_listenerLeft, _listenerRight);

    //Compass Activities
    compassView = (CompassView) this.findViewById(R.id.compassView);
    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    //  updateOrientation(new float[] {0, 0, 0});
    //  updateOrientation(calculateOrientation());

    // Hook up button presses to the appropriate event handler.
    // Quit Button -- not really necessary: The 'Back' button does 
    //   the same thing, but we create this just for fun..
    ((Button) findViewById(R.id.quitButton)).setOnClickListener(mQuitListener);

    tv_myAddr = (TextView) findViewById(R.id.myAddress);
    if (tv_myAddr != null)
        tv_myAddr.setText("<detecting>");
    mHandler.postDelayed(mUpdateMyAddress, 1000); // every 10 sec */

    //Updating Datalog fragment view
    tv_XVel = (TextView) findViewById(R.id.XVel);
    if (tv_XVel != null)
        tv_XVel.setText("<detecting>");

    tv_YVel = (TextView) findViewById(R.id.YVel);
    if (tv_YVel != null)
        tv_YVel.setText("<detecting>");

    tv_CompassDir = (TextView) findViewById(R.id.CompassDir);
    if (tv_CompassDir != null)
        tv_CompassDir.setText("<detecting>");

    tv_GPSLocation = (TextView) findViewById(R.id.GPSLocation);
    if (tv_GPSLocation != null)
        tv_GPSLocation.setText("<detecting>");

    tv_Log_DDS = (TextView) findViewById(R.id.loggingMessage);
    if (tv_Log_DDS != null)
        tv_Log_DDS.setText("<detecting>");

    mHandler.postDelayed(mUpdateDatalog, 500); // every 1 sec */
}