Here you can find the source of toLocalDateTime(String date, DateTimeFormatter formatter)
public static LocalDateTime toLocalDateTime(String date, DateTimeFormatter formatter)
//package com.java2s; //License from project: Open Source License import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; public class Main { public static LocalDateTime toLocalDateTime(String date, DateTimeFormatter formatter) { try {/* w w w . ja v a2s . c o m*/ ZonedDateTime zonedDateTime = toZonedDateTime(date, formatter); return LocalDateTime.ofInstant(zonedDateTime.toInstant(), ZoneId.systemDefault()); } catch (Exception e) { throw new IllegalArgumentException(e); } } public static ZonedDateTime toZonedDateTime(String date, DateTimeFormatter formatter) { try { return ZonedDateTime.parse(date, formatter); } catch (Exception e) { throw new IllegalArgumentException(e); } } }