How can I extract a datetime pattern from any string in Java?
The pattern is "YYYYMMddkm".
Are there any Joda time helper methods for this?
String 1: 2014041507393_somefile.somemore
String 2: _somefile2014041507393.somemore
Use the following regular expression:
^\d{4}-\d{2}-\d{2}$
as in
String date = "2014041507393_somefile.somemore";
if (str.matches("\\d{4}-\\d{2}-\\d{2}")) {
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With