how I can make my program to calculate the running time of a method once the user click JButton until the result shown in JTextBox? i don't want the whole program running time.thanks the code is this. and i have another error in the last line (long can't be converted to string). what i can do to set the result in jtextbox? and it still calculate the whole running time. what i want is to calculate only the encryption time to compare between different keys.
long startTime = System.currentTimeMillis();
byte[] plain = plaintext.getText().getBytes();
byte[] K = key.getText().getBytes();
byte[] encrypted = encrypt(plain, K);
String a = bytesToHex(encrypted);
encryptedtext.setText(a);
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
time.setText(elapsedTime);