Reputation: 1811
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
?
Upvotes: 1
Views: 90
Reputation: 60046
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
Upvotes: 3