How to extract the entire matching group in java regex

skr :

I have some data's like 2014-06-11T22:22:17

which i am matching using regex ([\d-])+T([\d:])+ in two different part by separating date and time like

2014-06-11 and 22:22:17 so i have created two groups

but when i am extracting the data like as below

Date =m.group(1);

it extract only digit "1" in Date String, why is it not extracting the entire group which is 2014-06-11?

YCF_L :

I would like to use LocalDateTime in your case to get the date and time separately like this :

LocalDateTime dateTime = LocalDateTime.parse("2014-06-11T22:22:17");
LocalDate date = dateTime.toLocalDate(); // 2014-06-11
LocalTime time = dateTime.toLocalTime(); // 22:22:17

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326481&siteId=1