-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimestampEmail.java
More file actions
46 lines (38 loc) · 1.38 KB
/
TimestampEmail.java
File metadata and controls
46 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.Date;
import java.text.SimpleDateFormat;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Clipboard;
class TimestampEmail {
private static final String BASE = "jrobertson+";
private static final String URL = "@hirevue.com";
public static void main(String[] args) {
// Validate email address
if (args.length != 1) {
System.out.println("Needs a valid email address as the only arg");
return;
}
String emailArg = args[0];
String[] split = emailArg.split("@");
if (split.length != 2) {
System.out.println("Needs a valid email address (missing an '@' symbol)");
return;
}
String base = split[0] + "+";
String url = "@" + split[1];
String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
String email = base + timeStamp + url;
// Print it for debugging purposes
System.out.println(email);
// Copy to the clipboard
StringSelection stringSelection = new StringSelection(email);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
// It will remove it from the clipboard when the program ends so pause for 5 seconds
try {
Thread.sleep(5000);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}