It is necessary to parse the date of the form 12:00 = 1200 I am writing a code:
public class RegexTest { public static void main(String args[]) { String pattern = "[0-9]+"; String text = "12:00"; Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(text); String a = null; while (m.find()) { a = text.substring(m.start(), m.end()) + "*"; } System.out.print(a); } } Displays only 00 , why does not write 1200 ?