If you just want a simple pattern the gets the numbers resembling a date and time, you could go with something using regular expressions with Pattern
and Matcher
like this:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestPattern {
public static void main(String[] args) {
Pattern datePatt = Pattern.compile(".*(\\d{4}/\\d{1,2}/\\d{1,2})\\s+(\\d{1,2}:\\d{1,3}).*");
Matcher matcher = datePatt.matcher("this internet will expires on 1397/7/16 22:300");
if (matcher.matches()) {
System.out.println(matcher.group(1));
System.out.println(matcher.group(2));
}
}
}
It will print the expected:
1397/7/16
2:300
If you don't know how to use regular expressions, start here:
https://www.regular-expressions.info/
And you could test them here:
https://www.regexpal.com
If you ever need something more elaborate check this question:
Regex to validate date format dd/mm/yyyy
cheers!