String datetime = "20180823141800";
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
LocalDateTime ldt = LocalDateTime.parse(datetime,dtf);
System.out.println(ldt);
DateTimeFormatter fa = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String datetime2 = ldt.format(fa);
System.out.println(datetime2); //datetime2 为转换后可存储在sql server中的datetime类型