You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't think of any other way except checking time string against multiple regex, and my regex is pretty bad.
For example here's one:
Pattern p = Pattern.compile("(?<year>\\d{4})[\\s\\-.](?<month>\\d{1,2})[\\s\\-.](?<day>\\d{1,2})"
+ "[\\s\\-.T](?<hour>\\d{1,2})[\\s\\-.:]?(?<minute>\\d{2})");
Matcher m = pattern.matcher(timeString);
m.matches();
Matcher.group(groupName) can then be used to access the individual capture groups.
If the pattern cannot be matched then I just store the raw string as time.
It will be great if anyone can share a elegant approach for parsing date and time.
Thanks in advance!
The text was updated successfully, but these errors were encountered:
I can't think of any other way except checking time string against multiple regex, and my regex is pretty bad.
For example here's one:
Matcher.group(groupName)
can then be used to access the individual capture groups.If the pattern cannot be matched then I just store the raw string as time.
It will be great if anyone can share a elegant approach for parsing date and time.
Thanks in advance!
The text was updated successfully, but these errors were encountered: