Java examples for java.time:LocalDateTime
parses string exclusively in this format "dd/mm/yyyy HH:mm" to LocalDateTime
//package com.java2s; import java.time.DateTimeException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public class Main { private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter .ofPattern("dd/MM/yyyy HH:mm"); /*** Methods ***/ // parses string exclusively in this format "dd/mm/yyyy HH:mm" public static LocalDateTime parseStringToDateTime(String inputString) { try {/*from ww w. j a va2 s . co m*/ return LocalDateTime.parse(inputString, DATE_TIME_FORMATTER); } catch (DateTimeException e) { return null; } } }