Skip to content

Instantly share code, notes, and snippets.

@ajbinky
Created March 28, 2019 20:16
Show Gist options
  • Save ajbinky/ec2266ec205808cbf7f5ea7bb8b16d47 to your computer and use it in GitHub Desktop.
Save ajbinky/ec2266ec205808cbf7f5ea7bb8b16d47 to your computer and use it in GitHub Desktop.
TimedResponse using System.currentTimeMillis()
package main.cis171.kelli.week09;
import javax.swing.*;
public class MyTimedResponse {
private static String question = "Who is your idol?";
public static void main(String[] args) {
long start, end;
start = System.currentTimeMillis();
JOptionPane.showInputDialog(question);
end = System.currentTimeMillis();
long seconds = (end / 1000) - (start / 1000);
String difference = "It took " + seconds + " seconds for you to answer.\nWas it a difficult decision?";
JOptionPane.showMessageDialog(null, difference, "Output", 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment