I have to allow user to input only time in ##:## format in edit text on the fly, is there any way to achieve it? I have used below code but it doest not working.
I a
Try casting the chars to ints, then test if they are greater than 24 and 60.
int a = ((int) result.charAt(0)) - 48;
int b = ((int) result.charAt(1)) - 48;
int c = ((int) result.charAt(3)) - 48;
if(a < 0 || b < 0 || c < 0) {
Not right.
}
if((a > 2 || (a == 2 && b > 3)) || c > 59) {
Neither is this.
}
Minus 48 because numbers 0 is 48th in the ascii table. The test has to be ascii.