I need to compare two values: finish time and start time which gotten from text fields in my program. I tried to use codes:
1). if (txtfinishTime.getText() <= txtstartTime.getText())
2). SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss");
long ET = formatter.parse(txtfinishTime.getText()).getTime();
long ST = formatter.parse(txtstartTime.getText()).getTime();
if(ET <= ST)
Both 1) and 2) are wrong. For 2). If I enter any time from 12:00:00 to 12:59:59 in the text field txtfinishTime, 9:00:00 in the text field txtstartTime, it returns true. But if I enter any time not from 12:00:00 to 12:59:59 and later than the txtstartTime 9:00:00, such as 9:30:00, it returns false.
Can anybody help me solve this problem? Thanks!!!!
Your second approach should work with the following modification. Change the line:
SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss");
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…