List of usage examples for java.text DateFormat getDateTimeInstance
public static final DateFormat getDateTimeInstance()
From source file:org.apache.webdav.lib.WebdavResource.java
/** * Get an array of pathnames and basic information denoting the WebDAV * resources in the denoted by this pathname. * * array 0: displayname/*from w w w .j a v a2 s. co m*/ * array 1: getcontentlength * array 2: iscollection or getcontentype * array 3: getlastmodifieddate * array 4: name * * @return An array of pathnames and more denoting the resources. * @exception HttpException * @exception IOException */ public Vector listBasic() throws HttpException, IOException { setBasicProperties(DepthSupport.DEPTH_1); Enumeration hrefs = childResources.getResourceNames(); Vector hrefList = new Vector(); while (hrefs.hasMoreElements()) { try { String resourceName = (String) hrefs.nextElement(); WebdavResource currentResource = childResources.getResource(resourceName); String[] longFormat = new String[5]; // displayname. longFormat[0] = currentResource.getDisplayName(); long length = currentResource.getGetContentLength(); // getcontentlength longFormat[1] = new Long(length).toString(); // resourcetype ResourceTypeProperty resourceTypeProperty = currentResource.getResourceType(); // getcontenttype String getContentType = currentResource.getGetContentType(); longFormat[2] = resourceTypeProperty.isCollection() ? "COLLECTION" : getContentType; Date date = new Date(currentResource.getGetLastModified()); // getlastmodified // Save the dummy what if failed. longFormat[3] = (date == null) ? "-- -- ----" : // Print the local fancy date format. DateFormat.getDateTimeInstance().format(date); hrefList.addElement(longFormat); // real name of componente longFormat[4] = currentResource.getName(); } catch (Exception e) { // FIXME: After if's gotten an exception, any solution? if (debug > 0) e.printStackTrace(); //log.error(e,e); } } return hrefList; }
From source file:com.f8full.casserolesencours.CasserolesEnCoursActivity.java
private void startTaskForId(int radioButtonID, final boolean manual) { String eventDescTemp = ""; //Will do for now, insure only one task at a time, we could have overlap if wanted later on cancelActiveTasks();// w ww. j av a2s . c o m final JSONObject newData = new JSONObject(); //Just a convenient map ? try { newData.put("DESC", "Scheduled poll"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } //That should be a switch if (radioButtonID == R.id.frequency0) { try { //Retrieve status message from ui in one function only newData.put("DESC", "Scheduled status update. UI says : " + ((EditText) findViewById(R.id.statusText)).getText().toString()); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } eventDescTemp = "frequency -- now: 10min"; //Threaded mLocPollFrq0 = mLocationPollThreadExecutor.scheduleAtFixedRate(new Runnable() { public void run() { try { newData.put("DATE", DateFormat.getDateTimeInstance().format(new Date())); newData.put("LOCATION", getLatLongPosition()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } //Threaded : httpTransport is Thread safe, hence concurrent access to the web should be handled writeToFusionTable(false, newData); } }, //60000, 60000, TimeUnit.MILLISECONDS); 10, 10, TimeUnit.MINUTES); } else if (radioButtonID == R.id.frequency1) { try { //Retrieve status message from ui in one function only newData.put("DESC", "Scheduled status update. UI says : " + ((EditText) findViewById(R.id.statusText)).getText().toString()); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } eventDescTemp = "frequency -- now: 5min"; //Threaded mLocPollFrq1 = mLocationPollThreadExecutor.scheduleAtFixedRate(new Runnable() { public void run() { try { newData.put("DATE", DateFormat.getDateTimeInstance().format(new Date())); newData.put("LOCATION", getLatLongPosition()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } //Threaded : httpTransport is Thread safe, hence concurrent access to the web should be handled writeToFusionTable(false, newData); } }, //30000, 30000, TimeUnit.MILLISECONDS); 5, 5, TimeUnit.MINUTES); } else if (radioButtonID == R.id.frequency2) { try { //Retrieve status message from ui in one function only newData.put("DESC", "Scheduled status update. UI says : " + ((EditText) findViewById(R.id.statusText)).getText().toString()); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } eventDescTemp = "frequency -- now: 3mins"; //Threaded mLocPollFrq2 = mLocationPollThreadExecutor.scheduleAtFixedRate(new Runnable() { public void run() { try { newData.put("DATE", DateFormat.getDateTimeInstance().format(new Date())); newData.put("LOCATION", getLatLongPosition()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } //Threaded : httpTransport is Thread safe, hence concurrent access to the web should be handled writeToFusionTable(false, newData); } }, //15000, 15000, TimeUnit.MILLISECONDS); 3, 3, TimeUnit.MINUTES); } else if (radioButtonID == R.id.frequency3) { try { //Retrieve status message from ui in one function only newData.put("DESC", "Scheduled status update. UI says : " + ((EditText) findViewById(R.id.statusText)).getText().toString()); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } eventDescTemp = "frequency -- now: 1min"; //Threaded mLocPollFrq3 = mLocationPollThreadExecutor.scheduleAtFixedRate(new Runnable() { public void run() { try { newData.put("DATE", DateFormat.getDateTimeInstance().format(new Date())); newData.put("LOCATION", getLatLongPosition()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } //Threaded : httpTransport is Thread safe, hence concurrent access to the web should be handled writeToFusionTable(false, newData); } }, //5000, 5000, TimeUnit.MILLISECONDS); 1, 1, TimeUnit.MINUTES); } final String eventDesc = eventDescTemp; //This is to thread the input of the changing frequency message, that's why tasks are delayed by their frequency new Thread((new Runnable() { public void run() { //Threaded : httpTransport is Thread safe, hence concurrent access to the web should be handled writeToFusionTable(manual, eventDesc); } })).start(); }
From source file:com.codename1.impl.android.AndroidImplementation.java
/** * @inheritDoc//w ww . j a va2s . co m */ public L10NManager getLocalizationManager() { if (l10n == null) { Locale l = Locale.getDefault(); l10n = new L10NManager(l.getLanguage(), l.getCountry()) { public double parseDouble(String localeFormattedDecimal) { try { return NumberFormat.getNumberInstance().parse(localeFormattedDecimal).doubleValue(); } catch (ParseException err) { return Double.parseDouble(localeFormattedDecimal); } } public String format(int number) { return NumberFormat.getNumberInstance().format(number); } public String format(double number) { return NumberFormat.getNumberInstance().format(number); } public String formatCurrency(double currency) { return NumberFormat.getCurrencyInstance().format(currency); } public String formatDateLongStyle(Date d) { return DateFormat.getDateInstance(DateFormat.LONG).format(d); } public String formatDateShortStyle(Date d) { return DateFormat.getDateInstance(DateFormat.SHORT).format(d); } public String formatDateTime(Date d) { return DateFormat.getDateTimeInstance().format(d); } public String formatDateTimeMedium(Date d) { DateFormat dd = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); return dd.format(d); } public String formatDateTimeShort(Date d) { DateFormat dd = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); return dd.format(d); } public String getCurrencySymbol() { return NumberFormat.getInstance().getCurrency().getSymbol(); } public void setLocale(String locale, String language) { super.setLocale(locale, language); Locale l = new Locale(language, locale); Locale.setDefault(l); } }; } return l10n; }