List of usage examples for java.text DateFormat getDateTimeInstance
public static final DateFormat getDateTimeInstance()
From source file:fileops.FileChooser.java
/** * Method to fill the current layout with files and folders from the * external directory/*from www. jav a 2s. c o m*/ * * @params: Path for the SD Card */ void fill(File f) { File[] dirs = f.listFiles(); /* * if(f.getName().equalsIgnoreCase(Environment.getExternalStorageDirectory * ().getName())) getActivity().getActionBar().setTitle("SD Card"); else * getActivity().getActionBar().setTitle(f.getName()); */ List<Item> dir = new ArrayList<Item>(); List<Item> fls = new ArrayList<Item>(); try { for (File ff : dirs) { Date lastModDate = new Date(ff.lastModified()); DateFormat formater = DateFormat.getDateTimeInstance(); String date_modify = formater.format(lastModDate); if (ff.isDirectory()) { File[] fbuf = ff.listFiles(); int buf = 0; if (fbuf != null) { buf = fbuf.length; } else buf = 0; String num_item = String.valueOf(buf); if (buf == 0) num_item = num_item + " item"; else num_item = num_item + " items"; // String formated = lastModDate.toString(); dir.add(new Item(ff.getName(), num_item, date_modify, ff.getAbsolutePath(), "directory_icon")); } else { fls.add(new Item(ff.getName(), ff.length() + " Byte", date_modify, ff.getAbsolutePath(), "file_icon")); } } } catch (Exception e) { } Collections.sort(dir); Collections.sort(fls); dir.addAll(fls); if (!f.getName().equalsIgnoreCase(Environment.getExternalStorageDirectory().getName())) dir.add(0, new Item("..", "Parent Directory", "", f.getParent(), "directory_up")); adapter = new FileArrayAdapter(getActivity(), R.layout.file_view, dir); this.setListAdapter(adapter); }
From source file:com.microsoft.tfs.client.common.ui.controls.generic.DatepickerCombo.java
/** * Creates a new DatepickerCombo, using the default Locale and default * DateFormat to format dates that are selected using the popup Datepicker * control./* w w w . j ava2 s . c o m*/ */ public DatepickerCombo(final Composite parent, final int style) { this(parent, style, DateFormat.getDateTimeInstance()); }
From source file:com.bonsai.btcreceive.WalletService.java
private MyDownloadListener mkDownloadListener() { return new MyDownloadListener() { protected void progress(double pct, int blocksToGo, Date date, long msecsLeft) { Date cmplDate = new Date(System.currentTimeMillis() + msecsLeft); mLogger.info(String.format("CHAIN DOWNLOAD %d%% DONE WITH %d BLOCKS TO GO, COMPLETE AT %s", (int) pct, blocksToGo, DateFormat.getDateTimeInstance().format(cmplDate))); mBlocksToGo = blocksToGo;/*from w w w . j av a2s .c om*/ mScanDate = date; mMsecsLeft = msecsLeft; if (mPercentDone != pct) { mPercentDone = pct; setState(State.SYNCING); } } }; }
From source file:gov.whitehouse.ui.fragments.app.ArticleViewerFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Bundle args = getArguments();//from w w w. j a v a 2 s . c o m mPageInfo = new JSONObject(); try { mPageInfo.put("title", args.getString("title")); final SimpleDateFormat date = new SimpleDateFormat("MMM d, yyyy h:mm a"); final DateFormat parse = DateFormat.getDateTimeInstance(); mPageInfo.put("date", date.format(parse.parse(args.getString("date")))); mPageInfo.put("creator", args.getString("creator")); mPageInfo.put("description", args.getString("description")); mPageInfo.put("url", args.getString("url")); mWebView.loadUrl(PAGE_TEMPLATE_URL); } catch (JSONException e) { Log.e(TAG, "error creating JSON object for post", e); } catch (ParseException e) { } mArticleType = args.getInt(ARG_FEED_TYPE, ARTICLE_TYPE_FEED); mUpTitle = args.getString(ARG_UP_TITLE); if (!((BaseActivity) getSherlockActivity()).isMultipaned()) { switch (mArticleType) { case ARTICLE_TYPE_FEED: getSherlockActivity().getSupportActionBar().setTitle(mUpTitle.toUpperCase()); break; case ARTICLE_TYPE_FAVORITES: getSherlockActivity().getSupportActionBar().setTitle(R.string.favorites); break; } } final String json = args.getString(ARG_ITEM_JSON); if (json != null) { mFeedItem = GsonUtils.fromJson(json, FeedItem.class); } mFavorited = FavoritesUtils.isFavorited(getSherlockActivity(), mFeedItem); }
From source file:net.risesoft.soa.asf.web.controller.SystemController.java
private List<SysInfo> getVMInfo() { List list = new ArrayList(); String group = "3. VM ?"; RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); list.add(new SysInfo("BootClassPath", rt.getBootClassPath(), group)); list.add(new SysInfo("ClassPath", rt.getClassPath(), group)); list.add(new SysInfo("LibraryPath", rt.getLibraryPath(), group)); list.add(new SysInfo("ManagementSpecVersion", rt.getManagementSpecVersion(), group)); list.add(new SysInfo("Name", rt.getName(), group)); list.add(new SysInfo("SpecName", rt.getSpecName(), group)); list.add(new SysInfo("SpecVendor", rt.getSpecVendor(), group)); list.add(new SysInfo("SpecVersion", rt.getSpecVersion(), group)); list.add(new SysInfo("VmName", rt.getVmName(), group)); list.add(new SysInfo("VmVendor", rt.getVmVendor(), group)); list.add(new SysInfo("VmVersion", rt.getVmVersion(), group)); list.add(new SysInfo("StartTime", DateFormat.getDateTimeInstance().format(new Date(rt.getStartTime())), group));/*www. j a va 2 s . c om*/ list.add(new SysInfo("UpTime", this.helper.getUpTimeStr(rt.getUptime()), group)); list.add(new SysInfo("InputArguments", rt.getInputArguments(), group)); group = "6. ?"; Map<String, String> sysProps = rt.getSystemProperties(); for (Map.Entry entry : sysProps.entrySet()) { list.add(new SysInfo((String) entry.getKey(), entry.getValue(), group)); } Collections.sort(list, new Comparator() { public int compare(SystemController.SysInfo o1, SystemController.SysInfo o2) { String key1 = o1.getKey(); String key2 = o2.getKey(); return key1.compareToIgnoreCase(key2); } }); return list; }
From source file:com.redhat.rhn.testing.RhnBaseTestCase.java
/** * Assert that the date <code>later</code> is after the date * <code>earlier</code>. The assertion succeeds if the dates * are equal. Both dates must be non-null. * * @param msg the message to print if the assertion fails * @param earlier the earlier date to compare * @param later the later date to compare *///from ww w. ja va 2 s . c o m public static void assertNotBefore(String msg, Date earlier, Date later) { assertNotNull(msg, earlier); assertNotNull(msg, later); if (earlier.after(later) && !earlier.equals(later)) { String e = DateFormat.getDateTimeInstance().format(earlier); String l = DateFormat.getDateTimeInstance().format(later); throw new ComparisonFailure(msg, e, l); } }
From source file:com.darizotas.metadatastrip.FileDetailFragment.java
/** * Creates the Share Intent that contains the * @param container Metadata container./* w w w .j a v a 2s . c om*/ * @return Intent for sharing. */ private Intent getShareIntent(MetaDataContainer container) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_SUBJECT, "[" + getResources().getString(R.string.app_name) + "] " + getResources().getString(R.string.share_subject) + " " + container.getFileName()); intent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.share_text) + " " + DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime())); try { // http://stackoverflow.com/questions/3272534/what-content-type-value-should-i-send-for-my-xml-sitemap // http://www.grauw.nl/blog/entry/489 intent.setType("application/xml"); //https://developer.android.com/training/sharing/send.html#send-binary-content //https://developer.android.com/reference/android/support/v4/content/FileProvider.html mStripFile = getMetadataFile(container); Uri uri = FileProvider.getUriForFile(getActivity(), "com.darizotas.metadatastrip", mStripFile); intent.putExtra(Intent.EXTRA_STREAM, uri); } catch (IllegalArgumentException e) { // Invalidates the intent. intent.setType(null); } return intent; }
From source file:de.xwic.sandbox.server.installer.XmlExport.java
/** * @param plDump// w w w .j a v a 2s .c o m */ public void exportPicklists(File plDump) throws IOException, ConfigurationException { Document doc = DocumentFactory.getInstance().createDocument(); Element root = doc.addElement(ELM_EXPORT); root.addAttribute("type", "picklists"); Element info = root.addElement(ELM_EXPORTDDATE); info.setText(DateFormat.getDateTimeInstance().format(new Date())); Element data = root.addElement(ELM_DATA); addPicklisten(data); OutputFormat prettyFormat = OutputFormat.createPrettyPrint(); OutputStream out = new FileOutputStream(plDump); XMLWriter writer = new XMLWriter(out, prettyFormat); writer.write(doc); writer.flush(); out.close(); }
From source file:com.daon.identityx.samplefidoapp.IntroActivity.java
/*** * The login has been successful and the server has returned a session Id and some additional * details to present to the user./*from w w w . j a v a 2 s .c o m*/ * * @param response the create session response */ protected void showLoggedIn(CreateSessionResponse response) { try { attemptingAuthentication = false; CoreApplication.setSessionId(response.getSessionId()); CoreApplication.setEmail(response.getEmail()); Intent newIntent = new Intent(this, HomeActivity.class); newIntent.putExtra("LOGGED_IN_WITH", response.getLoggedInWith().toString()); if (response.getLastLoggedIn() == null) { newIntent.putExtra("LAST_LOGGED_IN", getString(R.string.message_first_login)); } else { String dateString = DateFormat.getDateTimeInstance().format(response.getLastLoggedIn()); newIntent.putExtra("LAST_LOGGED_IN", dateString); } startActivity(newIntent); } catch (Throwable e) { displayError(e.getMessage()); } }
From source file:com.adito.rss.FeedManager.java
private static String getDateAsString(int checkAgainIn) { return DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis() + checkAgainIn)); }