I have a String
instance as following format:
yyyyMMddHHmmss
and I want split any element of it to a integer variable. for sample:
String date_time = "20080519145436";
By above string result must be:
int year = 2008;
int month = 05;
int day = 19;
int hour = 14;
int minutes = 54;
int second = 36;
I found two way for solve this issue:
- using a
SimpleDateFormatter
and fetch elements. - using
subString()
method ofString
class.
My question is: Which way is proposed? There are another ways?