input date format fixed. Some more output added.

This commit is contained in:
steckbrief 2017-11-17 19:23:57 +01:00
parent 5cacf94ecc
commit cdd12bae8a

View file

@ -16,8 +16,8 @@ import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.forward.packet.Forwarded;
public class MamLoader {
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd.MM.YYYY HH:mm:ss");
private static final SimpleDateFormat INPUT = new SimpleDateFormat("dd.MM.YYYY");
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
private static final SimpleDateFormat INPUT = new SimpleDateFormat("dd.MM.yyyy");
public static void main(String[] args) throws InterruptedException, SmackException, IOException, XMPPException {
if (2 > args.length) {
@ -60,6 +60,8 @@ public class MamLoader {
System.exit(1);
}
System.out.println("Your JID: " + myjid);
Console console = System.console();
if (null == console) {
System.out.println("Testenvironment!");
@ -72,6 +74,23 @@ public class MamLoader {
}
System.out.println("Loading history for chats with " + jid);
System.out.println("Limitations:");
if (null == start && null == end && -1 == limit) {
System.out.println("None");
} else {
if (null != start) {
System.out.println("Starting from: " + INPUT.format(start));
}
if (null != end) {
System.out.println("Ending at: " + INPUT.format(end));
}
if (-1 < limit) {
System.out.println("Only collecting " + limit + " messages. The limit is applied to all messages but only messages containing a body are printed out.");
}
}
if (debug) {
System.out.println("Debugging is enabled.");
}
MamLoadClient mlc = new MamLoadClient(debug);
try {
mlc.connectAndLogin(myjid, password);
@ -102,7 +121,7 @@ public class MamLoader {
return INPUT.parse(dateToParse);
} catch (ParseException e) {
System.err.println("Could not parse date: " + dateToParse);
System.err.println("Needed format: dd.MM.YYYY");
System.err.println("Needed format: dd.MM.yyyy");
System.exit(1);
return null;