Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add button to paste date #14

Open
ghost opened this issue Oct 2, 2017 · 1 comment
Open

Enhancement: Add button to paste date #14

ghost opened this issue Oct 2, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 2, 2017

Add button to paste date as in the format: yyymmdd as a string (ex: 20171002).

This is very helpful in writing diaries. Also very helpful for dating notes/todos/lists... etc.

I use it on my ubuntu with a keyboard button shortcut script to paste date and rename files:

/bin/bash -c "date +\"%Y%m%d\"| tr -d '\n' | xclip -selection clipboard && xdotool key Control_L+v"

@ghost
Copy link
Author

ghost commented Feb 6, 2018

This is how to do it:

Get current time & date:
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String currentDateandTime = sdf.format(new Date());
https://stackoverflow.com/questions/5369682/get-current-time-and-date-on-android

Copy text to system clipboard:
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(label, text); clipboard.setPrimaryClip(clip);
https://stackoverflow.com/questions/19253786/how-to-copy-text-to-clip-board-in-android

Paste text from systme clipboard:
private void onPaste(){ Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable t = c.getContents(this); if (t == null) return; try { jtxtfield.setText((String) t.getTransferData(DataFlavor.stringFlavor)); } catch (Exception e){ e.printStackTrace(); }//try }//onPaste
https://stackoverflow.com/questions/6631933/how-would-i-make-a-paste-from-java-using-the-system-clipboard#16694596

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants