public class Main {
	public static void main(String[] args) {
		// Test strings
		String[] wholeStringArr = { "The time is 7:00.", "The time is 7:00:05.", "The time is 7:00:05.1.",
				"The time is 7:00:05.123.", "The time is 7:00:05.123456789." };

		for (String wholeString : wholeStringArr) {
			String timeOnlyString = wholeString.replaceAll(".*?(\\d{1,2}:\\d{1,2}(?:\\:\\d{1,2}(?:\\.\\d{1,9})?)?).*",
					"$1");
			System.out.println(timeOnlyString);
		}
	}
}