I have an issue with java how can convert string 201204121458 to date format 2012/04/12 14:59 using a method ?
Thank you
I have an issue with java how can convert string 201204121458 to date format 2012/04/12 14:59 using a method ?
Thank you
This code snippet may help:
String str = "201204121458";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmm");
LocalDateTime dateTime = LocalDateTime.parse(str, formatter);
DateTimeFormatter printer = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
String formattedDateTime = dateTime.format(printer); // "2012/04/12 14:59"