Here you can find the source of isHourMinute(String str)
public static boolean isHourMinute(String str)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; public class Main { public static boolean isHourMinute(String str) { SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm"); dateFormat.setLenient(false);/*w w w. j a v a 2 s .c o m*/ try { dateFormat.parse(str); return true; } catch (Exception e) { return false; } } }