We can use .substring(start,end) to copy part of a String.
We can use Integer.parseInt to change a String to an int.
Assume that the String now contains
the current time in
the format "hh:mm". Use substring to copy the hh
part and the
mm part into separate Strings. Use Integer.parseInt to
convert
these to int values. Then use
if commands to decide whether
this time is earlier than
10:30 or not.
String now = "09:45" ;
String hh =
now.substring(0,2);
String mm =
now.substring(3,5);
int h = Integer.parseInt(hh);
int m = Integer.parseInt(mm);
if (h > 10)
{ output("later than
10:30"); }
else if (h == 10
&& m > 30)
{ output("later
than 10:30"); }
else
{ output("not
later than 10:30"); }