jeudi 6 juillet 2017

How to compare two different times using an if else statement?

I'm trying to compare two different times to see which comes before the other, but I'm having trouble coming up with an else if statement that compares their suffixes (am and pm) and outputs the order of the first time relative to the other time.

EDIT: the date type of suffix1 and suffix2 are strings, the data type of time1 and time2 are int

So far, I have this piece of code that checks if the periods are equal:

if (suffix1.equals(suffix2))
  {
       if (time1 > time2)
       {
          System.out.print("After");
       }
       .....
  }

is there a way to see which times' suffix comes before the other?

Aucun commentaire:

Enregistrer un commentaire