I am working on a piece of work where I need to get year, month, day from a String in Java. The string is like that: 20170119T163048
Where 2017 is year, 01 is month, 19 is day, 16:30:48 is time.
I implemented code like this below:
public void convertStringToDate (String string) {
String dateInString = "";
SimpleDateFormat formatter = new SimpleDateFormat();
Date date = formatter.parse("20170119T163048");
System.out.println(date);
}
But seems like it does not work. Looking around and I actually found quite lots of similar answer but none of them really work for me so...